Summary of common git commands

Corrections are welcome

Basic operations: 
git init turns the document structure into a manageable warehouse
git add adds a manageable file
git commit -m 'commit record information' submits the local file to the local warehouse
git status View file status
git clone <url> git clone
git log can display all submitted version information
git reflog can view all operation records of all branches (including commit and reset operations), including deleted commit records, git log cannot view deleted commit records


git rm< filename> Delete a file, similar to manual deletion in submission git reset --hard
HEAD^ roll back the document state to the previous 
state
100 Roll back the document to the last 100 states
git reset --hard View the file version number
git reset --hard 6fcffc8 9 Roll back the document to the state of the specified version number
git checkout --filename Roll back the specified document to the unmodified state workspace modification)


ssh-keygen -t rsa -C "[email protected]" Create SSH key


git remote add orgin http://github/XXXXXXXXXXXX Associate remote warehouse


git push orgin master Push to remote warehouse It is empty. When we pushed the master branch for the first time, we added the -u parameter (git push -u origin master), Git will not only push the contents of the local master branch to the remote new master branch, but also push the local master branch. The master branch is associated with the remote master branch, which simplifies commands for future pushes or pulls.


git clone url Clone a remote mirror
git remote View the information of the remote library
gir remote -v View the details of the remote warehouse


Branch operations: 
git branch View the branch status
git branch branch_name Create
a
branch And switch to branch_name branch 
git merge branch_name Merge baanch_name branch to current branch
git branch -d branch_name Delete the branch with the specified name


Pull and get:
git fetch <remote host name><remote branch name>:<local branch name> Create a new branch locally and download the branch in the remote library to the local branch
git fetch origin master:tmp 
//Create a new temp branch locally, Download the master branch code of the remote origin repository to the local temp branch


git pull <remote host name><remote branch name>:<local branch name> Retrieve a branch of the remote host, and then merge it with the local specified branch
git pull orgin Note for master b01    
:
 1. When the remote end changes, but the local library does not change, the remote end will overwrite the local library (the remote version is higher than the local one) in the pull operation.
   2. When the remote end is modified, the local library is also modified, and the pull operation Conflict files will be generated (the remote version conflicts with the local version)
 3. When the local library is modified, but the remote does not change, the pull will not change (the local version is higher than the remote version)
 3. When the local library version is lower than the remote version The terminal version cannot be pushed. You must first pull the operation


tag:
git tag View the tag
git tag <name> Switch to the branch that needs to be tagged, and type the command git tag <name> to enter a new tag
git tag <name > > <commit id> Tag on the specified version number
git show <tagname> to view the version status of the specified tag, commit id


git tag -d <tagname>delete the specified tag
git push orgin --tags push all tags to remote repository


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324636220&siteId=291194637
Recommended