Skip to content


Remove file from git tracking list

git rm --cached <file>

Git stash one particular file

git stash push -m "message" <file>

Git stage only those files which are tracked.

git add -u 

Git merge/rebase with strategy

I branched off the wrong branch in Git. How do I fix this?

git rebase --onto feature/XX-2 feature/XX-1 feature/XX-2-bkp

git submodule If you run this once, it ensures that when you pull you also get updates to any submodules in a repo:

git config --global submodule.recurse true

git pull even when you have made changes locally.

git config --global pull.rebase true

git config --global rebase.autoStash true

Reuse Recorded Resolution

Ever run into the same conflict more than once?

you can turn on a feature where Git memorizes the conflict and the resolution to it.

git config --global rerere.enabled true
git config --global rerere.autoUpdate true


sort branches by last commit date descending

git config --global column.ui auto
git config --global branch.sort -committerdate

  • Safe Force Pushing

    git push --force-with-lease
    git config --global alias.fpush push --force-with-lease

  • Sign commits by default

    git config gpg.format ssh
    git config user.signingkey ~/.ssh/