Or how to write a way too long title...
man git-*command*
Example: man git-commit
To see the diff of what is read
git log -> git log -p
git show -> git show -p
git stash show -> git stash show -p
git stash list -> git stash list -p
To manipulate patches instead of files
Used in git add
But also with git reset, git checkout, git stash!
Runs git fetch + git rebase origin/your-branch
instead of git fetch + git merge origin/your-branch
If branch diverged, local work will be on top of remote, with no merge commit
If branch did not diverge, same as git pull
Forces the creation of a merge commit when merging a branch in another
By default, if the branch to merge is ahead of destination, git fast-forwards the destination to the branch to merge
Merge of a branch without --no-ff
Merge of a branch with --no-ff
Stash the changes in a dirty working directory away
Works like a stack
Can be popped, cleared....
To stash away your work: git stash / git stash --patch
To retrieve the most recent stash, but leave the stash unchanged: git stash apply
To remove the most recent element of your stash stack: git stash drop
To retrieve the most recent stash without leaving it in the stack: git stash pop
To clear your stash stack: git stash clear
To create a named stash: git stash save "some message"
To list your stashes: git stash list
To remove the #th stash: git stash drop stash@{#}
to see a specific stash: git stash show stash@{#}
To clear your stash stack: git stash clear
programs you can place in a hooks directory to trigger actions at certain points in git's execution
Scripts located in .git/hooks
Examples:
pre-commit
prepare-commit-msg
post-commit
pre-rebase
.....
Must:
be executable
return 0 in case of success
return != 0 in case of error
Can:
be written in any language you fancy
Example of hooks:
pre-commit: Check that the code about to be commited is validated by the linter
post-commit: Take a picture of you each time you commit
Problem: Hooks are per workspace... how to automatically have them in every workspaces?
Solution: Templates!
Create a folder in your computer containing all the hooks you would like to automatically have in all your projects
Run:
git config --global init.templatedir 'path/to/the/folder/you/created'
To link the template directory to Git
To add the hooks in existing projects, run:
git init
in the projects
git config --global alias.st status
Or edit your ~/.gitconfig
git config --global alias.ba "branch -v -a"
git format-patch from-commit to-commit
Commit can be recreated with:
git am *patch-files*
Generates one file per commit
git format-patch master..HEAD
git format-patch master HEAD~5..HEAD
Example:
Useful to send a change to someone so he can apply it directly, while keeping you as commiter