GIT Cheatsheet
https://www.websequencediagrams.com/
participant HEAD
participant Index
participant WorkingTree
HEAD->WorkingTree:checkout
WorkingTree->Index:add
Index->HEAD:commit
HEAD Index WorkingTree
| | |
o------- checkout ------->o
| | |
| o<--- add ----o
o<--commit--o |
| | |
soft
mixed mixed
hard hard
--soft leaves index file & WorkingTree untouched. Undoes the last commit you made.--mixed resets index but not WorkingTree (default). You rolled back to before you ran all your git adds AND git commit--hard resets index & WorkingTree.git/info/exlude --> private repo ignore file.gitignore --> per directory and his subdirs... SHARED.gitignore
/dirname/ --> only directory ignore
*/dirname/ --> this dir in any subdir
/*.extension --> this extension
filename.ext --> this file only
git init
git remote add origin <URL>
origin is default name Creates an alias for the URL
git fetch --no-tags origin master:refs/remotes/origin/master
master name of the remote branch in the remote repo refs/remotes/origin/master is local path; The name of the remote tracking branch, local branch in remote's
git branch master origin/master
master local branch equivalent to --set-upstream-to=master
4.1. git rev-parse origin/master > .git/refs/heads/master
or equivalent command:
cp .git/refs/remotes/origin/master .git/refs/heads/master
4.2. git branch --set-upstream-to=origin/master
Sets local branch to track the remote branch stored in
refs/heads/master
Equivalent commands:
git config branch.{branch_name}.remote origingit config branch.{branch_name}.merge refs/heads/{remote_branch_name}
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
This is how we know which branch is default in the remote end. refs/remotes/origin/HEAD creates local file HEAD refers to
refs/remotes/origin/master
git checkout