1. Git repository Initialization
2. Configure user information:
3. Store the code in the. Git Repository:
1. Put the code in the GIT staging area:
2. Store the file at the warehouse entry to the version Library:
3. All modified files can be put into the version library at one time + command:Git commit -- all-M "some instructions"
4. view the current status
5. Ignore files in git
6. View logs
7. Roll Back to the specified version
git reset --hard Head~0
: Indicates to roll back to the status of the last code submission (may be 0, 1, 2 ...).
Git reset -- hard [version number]
: Accurately rolls back to a submitted status.
git reflog
: You can see the record of each version switch: You can see all submitted version numbers.
8. Branch
MASTER: Default master Branch
git branch dev
: Create a branch. The content of the branch is the same as that of the original branch.
git chechout dev
: Switch Branch
git branch
: View the current branches
git merge dev
: Merge Branch
git branch -d dev
: Delete Branch
When there is a conflict in the merge (manual merge is required), delete unnecessary components and resubmit the modified Code.
Submit code to GitHub
Obtain data from GitHub warehouse
git pull https://github.com/nameWangLong/test01.git master
+ Before downloading, You need to initialize a repositories.
Git clone [address]
: A New file is created to obtain the file in the remote warehouse. Multiple operations will overwrite the file.
Upload code using SSH:
Public Key and Private Key
Command for generating public and private keys:Ssh-keygen-t rsa-c "email"
Add the generated public key or private key to SSH in GitHub Project Settings
git push [email protected]:nameWangLong/test01.git master
Push and pull operation sequence:
Push and pull for simplified operations
First, define a Remote Variable pointing to the address:git remote add origin [email protected]:nameWangLong/test01.git master
Then add the-u parameter to the push type.git push origin -u master
After uploading and downloading, you only need to entergit push git pull
Simple use of Git