**
- Common commands
** `Submit code
git status
git add .
git commit -m “fix”
git push origin dev_20190510001
Query status
git status
View log
git log --stat
git reflog --date=iso
Create a branch
git status
git checkout -B dev_20190510001
git push
git push --set-upstream origin dev_20190510001`
Show file ls
Delete the file git rm test2.txt
and undo the operation git checkout – test.txt
Add files to cache:
git add test.txt single file
git add . all files in the current directory
Submit (including comments) to the local repository:
git commit -m 'First version submission'
Upload files to the remote repository:
git push origin [local branch name]: [remote branch name]
Of course, if your local branch name and remote branch name are the same, then you only need git push origin [branch name].
git push
Restore latest version of files
git fetch
git reset --hard origin/master //Restore to the remote warehouse and delete the git add and commit files
git pull pulls the latest version from the remote to the local and automatically merges it.
git fetch gets the latest version from the remote to the local. It will not merge automatically and needs to be merged manually.
git merge uses fetch to see the updates clearly before merging. situation, and then decide whether to merge.
git merge --abort aborts merge
git One branch completely covers another branch, as follows: dev_20210729 overwrites develop
$ git checkout develop
$ git reset --hard dev_20210729
$ git push origin develop --force
不允许推送 You are not allowed to force push code to a protected branch on this project
“Settings” -> “Repository” -> scroll down to “Protected branches”.
git rollback to the previous version http://www.cnblogs.com/yu-hailong/p/10681905.html
git log query calendar records
git reset --hard 5fa86ae3758e7e2a86825452977da40f34b6dd58 roll back to the previous version
git push origin HEAD --force force submit
Restore local files git reset -hard
git reset —soft + version number
rolls back to a certain version, only the commit information is rolled back, and the modified code will not be changed.
git reset --soft HEAD^
git reset --hard + version number
git reset --hard origin
completely rolls back to a certain version, and the local code will also change the content of the previous version.
#Return to a certain version of the local warehouse git reflog --date=iso
git reset --hard bae168
Roll back the local warehouse to the last commit
git reset –-hard
git reset --hard HEAD
Go back to the previous version of the current version
git reset --hard HEAD^
Go back to the previous version of the current version
git reset --hard HEAD^^
Go back to 100 versions before the current version
git reset --hard HEAD~100
Discard local submissions and force back to the latest online version
git fetch --all
git reset --hard origin/the branch you want to pull down (default master)
git fetch
vi /etc/ssh/sshd_config
View version:
git --version
View configuration:
git config --list
Set configuration:
git config --global pack.windowMemory 1024m
git config --global pack.packsizelimit 1g
git config --global http.postBuffer 1g
Delete configuration:
git config --global --unset pack.deltacachesize
https://edu.aliyun.com/jiaocheng/1834?spm=5176.11182473.menu.7.k6ksTN
Create branch command (copy files under the current branch):
git branch (branchname)
Submit a branch to the warehouse command:
git push origin (branchname)
Switch branch command:
git checkout (branchname)
Basic command to list branches:
git branch -a
Delete branch command:
git branch -d (branchname)
Create a new branch and immediately switch to it.
git checkout -b newtest
will prompt an error if there is a branch with the same name.
Force the creation of a new branch and overwrite the existing branch with the same name.
git checkout -B new_branch
Set the local branch to associate the remote branch
git push --set-upstream origin
Merge branches:
git checkout master
git merge test // Merge test branch to master branch
git push origin master
View branch git branch -a
Delete local branch git branch -D branch-name
Delete remote branch git push origin --delete branch-name or git push origin -d branch-name
Check which remote repositories are currently configured
git remote -v
Completely delete the file – the corresponding submission record will be deleted (including the submission history of normal files)
git filter-branch --force --index-filter 'git
rm --cached --ignore-unmatch test completely delete.txt' –prune
-empty --tag-name-filter cat – --all
git push --all --force
Modify the branch name https://www.jianshu.com/p/cc740394faf5
a. Rename the local branch corresponding to the remote branch
git branch -m oldName newName
b. Delete the remote branch
git push --delete origin oldName
c. Upload the newly named local branch
git push origin newName
d. Associate the modified local branch with the remote branch
git branch --set-upstream-to origin/newName