git add git add --update # add all modified files that were already tracked (it will not add new files) git add . # add all modified and new files from this folder git add -A # add all modified and new files (from the root of the project) git branch git branch # list all local branches git branch -a # list all branches git branch -r # list all remote branches git branch -d # delete branch (only works for fully merged branches) git branch -D # delete branch, also when not merged git branch --no-merged # list branches that are not merged to current (or specified) branch git branch --merged # list branches that are merged to current (or specified) branch git branch -r --merged # idem : ook voor remote branches git blame git blame # annotate the file git bisect git bisect # interactive binary search of the commit that introduced a bug git cherry-pick git cherry-pick [sha-1] # rebase specified commit to the top of current branch git commit git commit # commit files (files must be added before with the git add command) git commit -a # add all modified files (not new files) git commit -m msg # add message to commit git clean git clean # remove untracked files from the working tree git clean -d # also remove untracked directories git clean -X # remove only files ignored by git git checkout git checkout [branch] # switch to existing branch git checkout -b [branch] # switch to branch, if branch does not exists: create it git checkout -b [br] [rmt]/[br] # make a local copy of branch fetched from remote git diff git diff # compare current with staged (or with last commit if no staged one) git diff --staged # compare staged with last commit git diff [master]..[br] # show diff between master and br git diff [master]...[br] # show diff introduced by topicbr comparing to master git diff [sha-1] # show diff between latest commit of current branch and other commit git diff --name-only # show only filenames git fetch git fetch # get data from remote (not merge with local) git fetch --all # fetch all remotes git fetch origin dev:dev # update de dev branch zonder deze uitgechecked te hebben git log git log --graph # graphical view git log --decorate # add branches git log --oneline # one line per commit git log --simplify-by-decoration # only show branches git log ..[branch] # list all commits between head and specified branch git log [br1]..[br2] # list all commits between 2 branches git log --grep=”WEB-111” # only list commits with this comment in commit message git log -S"new" # only list commits with this comment in source changes git log [br1] --not [br2] # list commits which are in br1 but not in br2 git log [br1] [br2] --not [br3] # list commits which are in br1 and br2 but not br3 git log [master]..[topicbr] # show commits that reachable from topic but not from master git log origin/master..HEAD # show what will be pushed to remote in case of push git log [master]…[topic] # show commits not reachable from both branches git merge git merge [branch] # merge specified branch into current git merge-base git merge-base [br1] [br2] # show common ancestor of the two branches git pull git pull [remote] # get data from remote and merge into local git push git push [remote] [branch] # send branch state to remote git push [remote] [[local]:[rmote]] # same but with diff name of remote branch git push [origin] :[rmotebr] # remove branch on remote server git push [remote] [tag] # push tag to remote git push [remote] —tags # push all tags to remote git push origin --delete [banch] # delete remote brnach git rebase git rebase [branch] # rebase current branch to the latest commit of [branch] git rebase -i HEAD~3 # change last 3 commits (like amend but for n commits) git rebase --abort # abort a rebase git rebase --continue # continue a rebase git remote git remote # show all remote aliases git remote -v # verbose: show urls git remote add # add remote git remote show origin # show info on remote git remote rm [remote] # delete remote reference git reset git reset HEAD [file] # unstage file or all files git checkout -- [file | *] # revert unstaged file (* for all files) to last commit state git reset --hard origin/master # revert to remote state git reflog git reflog # show the reflog git reflog --date=iso # show the timestamp to the reflog git show git show [sha] # shows one or more objects (blobs, trees, tags and commits). git show HEAD # show head info git status git status # show status git status -sb # show all files on 1 line git tag git tag # list all available tags git tag -l “*” # filter tags by pattern git tag [name] # create lightweight tag for last commit git tag [name] [sha-1] # create tag for not the latest commit git tag -a [name] -m [msg] # create annotated tag (-s instead -a --] signed tag) git show [tag name] # show commit marked by tag, and tag’s info git tag -v [tag name] # verify signed tag ***** GIT FLOW ***** git flow init git init git commit --allow-empty -m "Initial commit" git checkout -b develop master edit .git/config : configure feature, release, hotfix prefixes git flow feature start MYFEATURE git checkout -b feature/MYFEATURE develop git flow feature publish MYFEATURE git checkout feature/MYFEATURE git push origin feature/MYFEATURE git flow feature pull origin MYFEATURE git checkout feature/MYFEATURE git pull --rebase origin feature/MYFEATURE git flow feature finish MYFEATURE git checkout develop git merge --no-ff feature/MYFEATURE git branch -d feature/MYFEATURE git flow release start 1.2.0 git checkout -b release/1.2.0 develop git flow release publish 1.2.0 git checkout release/1.2.0 git push origin release/1.2.0 git flow release finish 1.2.0 git checkout master git merge --no-ff release/1.2.0 git tag -a 1.2.0 git checkout develop git merge --no-ff release/1.2.0 git branch -d release/1.2.0 git flow hotfix start 1.2.1 [commit] git checkout -b hotfix/1.2.1 [commit] git flow hotfix finish 1.2.1 git checkout master git merge --no-ff hotfix/1.2.1 git tag -a 1.2.1 git checkout develop git merge --no-ff hotfix/1.2.1 git branch -d hotfix/1.2.1