Just some personal git-foo I want to reference.
git commit --amend
: Shove changes onto last commit (easy rebase if you want to add more to previous commit)git config --list
: I use it to find if the clone is using https or ssh
git config remote.origin.url git@xxx.git
: Set your project to use SSH (grab the full SSH URL from the repo page)git fetch && git diff master..origin/master --name-status
: Get list of incoming changes from the remote origin.
--name-only
For just namesgit filter-branch
: If you want to remove some changes to some files in a branch across all commits in the feature-branch.
git filter-branch --force --tree-filter 'git checkout {some-commit-sha} -- some-file.js; {other-commands-if-you-want-like-rm-or-other-git-checkouts}' --prune-empty develop..feature/some-feature-branch
git show :/myqueryhere
: search commitsgit branch --contains {some-commit-sha}
: Find which branchs have a certain commitgit reset --soft HEAD^
: Undo but keep changes in working copygit log develop.. --oneline
: List only commits on feature branch based off of develop
git config --global rerere.eneabled 1
: Eases merging (why not do this?)git config --global color.ui 1
: Add color to CLIYou can use the
prepare-commit-msg
hook to do so.Copy
.git/hooks/prepare-commit-msg.sample
to.git/hooks/prepare-commit-msg
The example inside it actually adds # to the Conflicts part:
case "$2,$3" in merge,) /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
This hook makes sense because previous versions were doing this by default (like in
Linux git version 1.7.10.4
).
Now what you want to do is exactly the opposite: removing
#
on the Conflicts part. Indeed, thegit version 2.6.2.windows.1
comments out by default the Conflicts part so you can just update the command inprepare-commit-msg
with:/usr/bin/perl -i.bak -ne 's/^#// if /^# Conflicts/ .. /^#\R/; print' "$1" ;;
git rebase master
?