Git Basics

git commit --amend -m ""

Error prompt

error: failed to push some refs to ''
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes

**This is because the remote warehouse has been modified, so fetch first and then pull
Finally, you can push**

Error submitting remote warehouse

src refspec master does not match any
Error submitting remote warehouse, no add, commit

Git basic command

Git global cofig
git config --global "John Doe
git config --global [email protected]
Git init
Git add/commit -m
Git log: history, recent to farthest
Git reset – - hard head ^ or head ~ 100 // fallback 100
Git reset – hard Sha
There is a head pointer pointing to the head
Git reflog: record each command
Work tree  stagereposity
Git diff head - file name // view work tree and repo
git diff HEAD -- readme. The difference between the latest version in txt workspace and version Library
Change git checkout of GIT checkout discard work tree – file name
Git reset can either roll back the version or undo the changes in the staging area
Delete the file in the work tree, GIT RM: delete the file from the library, and then commit to delete it from the library
            Git checkout – file name recovery from repository

The GIT log -- graph command can see the branch merge graph.
Git remote add origin (first name)
git remote add origin
Git push - U origin master // the first time
git push origin master
Git clone remote library
Master points to the latest submission, and head points to master
Git checkout - B feature1 // create a branch and convert to a branch

Git branch establish branch
Git checkout branch name, go to branch
The GIT branch command will list all branches, and the current branch will be preceded by a * sign
Git merge dev is merged into the dev branch -- no FF parameter, which means fast forward is disabled
Git branch - D dev delete branch

The GIT log -- graph command can see the branch merge graph.
Git stash list
Git stash pop, return to the work site, discard stash
Git remote – V // remote information
Git push origin < branch name > push your own modifications;
If the push fails, you need to use git pull to try to merge because the remote branch is newer than your local branch;
If git pull prompts no tracking information, it indicates that the link relationship between the local branch and the remote branch has not been created. Use the command git branch -- set upstream to < branch name > origin / < branch name >.
Git tag < tagName > is used to create a new tag
Git show < tagName > View tag information:
git tag -a <tagname> -m "blablabla..." Label information can be specified;
Git tag can view all tags.
Git tag - d < tagName > can delete a local tag;
• the command git push origin < tagName > can push a local label;
• the command git push origin -- tags can push all local tags that have not been pushed;

Git push origin: refs / tags / < tagName > can delete a remote tag.
Git show HEAD
Git config –list –show-origin
Differences between git diff work tree and stage
Git diff –staged
. gitignore can ignore unnecessary files
Blame:last modification on each line of file
Git push – u error, control panel / user / credential manager

Git delete commit

git rebase -i HEAD~

The order is reversed

Git clone a branch

git branch -a
git checkout -b bugfix-2.0x origin/bugfix-2.0.x
git pull origins
git remote show origin
Git checkout -- track origin / serverfix // local serverfix tracks remote serverfix

Git local / remote branch name modification

Git branch - R // list remote branches
Git branch - A // list all, including remote and local
git branch -v//verbose
git branch -m old_name new_name
git push origin  --delete  origin/old_ Name // Delete remote branch
 Git push origin serverfix // local serverfix tracks remote serverfix
git pull  -u origin  new_ name:newname   new_ Name track remote newname
Git remote prune origin // the remote has been deleted, but the remote of your own fetch is still there. Use prune

Git remote

git remote -v //verbose
git remote add pb //Add remote
Git remote show origin // view remote
Git remote remove origin // remove
Git remote rename Pb Paul // duplicate name

git log

Git log - P - 2 // the last two commit
git log --stat
git log --pretty=oneline
git log --pretty=format:"%h -- %an--%ar--%s"
Git log since = 2019.01.01 // since 2019.01.01
git log until=2019.01.01
git log --since=2.weeks/2.months/2.years
git log -S function_name