Git - yenbohuang/techNotes GitHub Wiki
- Pro Git https://git-scm.com/book/en/v2
- Eclipse EGit https://wiki.eclipse.org/EGit/User_Guide
- Forking workflow https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow
- master
- The default name for a starting branch when you run git init.
- origin
- The default name for a remote when you run git clone.
- Tracking branch and upstream branch
- Checking out a local branch from a remote-tracking branch automatically creates what is called a "tracking branch".
- And, the branch it tracks is called an "upstream branch".
- Tracking branches are local branches that have a direct relationship to a remote branch.
Configurations are set in ~/.gitconfig.
git config --global user.name "John Doe"
git config --global user.email [email protected]Configure Git on OS X or Linux to properly handle line endings
git config --global core.autocrlf inputConfigure Git on Windows to properly handle line endings
git config --global core.autocrlf truehttps://help.github.com/en/articles/configuring-git-to-handle-line-endings
git config --listgit clone https://github.com/libgit2/libgit2Show complete details:
git statusShow simple status:
git status -sgit add <file or directory>git mv <old file name> <new file name>git checkout -- <file>Commit files (no need to use git add) with message:
git commit -a -m <message>Commit and open default editor:
git commitCommit with message:
git commit -m <message>Change commit message or add forgotten files:
git commit --amendgit rm <file or directory>If you modified the file and added it to the index already, you must force the removal with the -f option:
git rm -f <file or directory>Keep the file in your working tree but remove it from your staging area:
git rm --cached <file or directory>git reset HEAD <file>git reset --hard HEAD^git remote -v
git remote show <remote name>Add a new remote Git repository as a remote name:
git remote add <remote name> <url>Add a remote for your local git that references upstream:
git remote add upstream <url>git pullgit push <remote name> <branch name>Push "master" branch to "origin" server:
git push origin mastergit remote prune originCreate a branch:
git branch <branch name>Switch to a branch:
git checkout <branch name>Create and switch to a branch
git checkout -b <branch name>Push a branch to remote:
git push <remote name> <branch name>Push a branch to where you pulled it:
git push origin <branch name>git branch -vvMerge branch back to master:
git checkout master
git merge <branch name>Update master to branch:
git checkout <branch name>
git merge mastergit branch -d <branch name>- git cherry-pick says “…38c74d is a merge but no -m option was given”
- Git cherry-pick syntax and merge branches
git cherry-pick <commit SHA>
git cherry-pick -m <# of parent starting from 1> <commit SHA>Point environment variable HOME to another folder.
See details in https://superuser.com/questions/1183044/how-can-i-change-my-mingw-msys-mintty-home-directory.