Basic use of git and github use warehouse to pull and submit
git use
1. Basic use
1. Global configuration is required for first use:
Configure the user name and email.
Check whether the user name and email are successfully configured.
The user name and email address are set globally, and all Git warehouse submissions will use this username and email address.
2. Create a test folder
The default location is on the desktop (the command operation is the same as liunx)
mkdir test_git
3. Enter the file initialization warehouse
git init
sets this hidden project to see .git
or ll -a to view hidden files
git status, query the status of all files in the current workspace
On branch master: The current branch master
No commits yet:
nothing to commit (create/copy files and use “git add” to track): No commit is currently being made, you can create or copy files and use "git add" Command to track
Add files to the cache
Syntax 1: git add file name
Syntax 2: git add file 1 file name 2 file name 3…
Syntax 3: git add. (There is a point) [add the current directory to the cache]
Add the readme.txt file to the cache area
git add readme.txt
error occurred fatal: pathspec'readme.txt' did not match any files
solution
touch create file
Use git status again to view the status of the file
The git commit -m "comment content" command submits the files in the cache area to the repository
2. Version rollback
1. First follow the above steps to add and submit test.py
2. Two ways to view the version change log command
The yellow part is the version number, followed by the comment content.
Generally use the second git log --pretty=oneline
version rollback: git reset --hard version number
git reset --hard 06e35cc1f9d4228ab4a7a24bf266cf36d4d32583
Before
rollback After rollback
Go back to the latest version
1. Git reflog View historical version
2. Find the corresponding version number
3. Git reset --hard 0a0795b Go back to the latest version
github use
1. The creation of remote warehouse
1. Interface translation
2. Warehouse naming and setting
2. Clone the project
1. Create an empty directory first
2. Use git clone to clone the online warehouse to the local
git clone https://github.com/Theshy0000/python_api.git
warning: You appear to have cloned an empty repository.
Prompt that a new repository has been cloned (don’t care if it is empty). The
clone is successful
2. Submit documents to the online warehouse
1. Submit the content of the workspace to the github remote warehouse
First move the target file to the python_api directory
2. Perform file submission operations (cache area, local warehouse) [don't forget]
View current file working path
Submit to cache area
Cache area to local warehouse
3. Submit to online operation (requires token)
git push origin master
4. Get the token
To Github Get your own Personal Access Token, the home page to enter the set
point here
Click here to
point this generates a new token
password
after entering the password to this
translation at the top of the screen
set up point above the
then net blown up
do not panic, points this look , Go back, the next step is coming, it should be fine
5. Fill in the token and click sign in
6. Check if the upload is successful
success
3. Pull online warehouse file operation
1. Online warehouse creation file
File name and file content, click Create.
Created successfully
2. Pull online warehouse files to local
An
error occurred during git pull pull down. It
would be fine to pull it again,
but test.py did not pull down. Is there any advice from the boss?
Error one
Error two
Reference document https://www.cnblogs.com/gian-t87/p/14513056.html