March 13, 2025 (updated May 7, 2025)
This is a simple reference listing Git commands I use often but tend to forget.
—
Create a new branch:
git branch <branch-name>
—
Switch to a branch:
git checkout <branch-name>
or
git switch <branch-name>
—
Create a new branch and switch to it in one go:
git checkout -b <branch-name>
—
List remote repositories:
git remote -v
—
Change remote repository URL:
git remote set-url origin <new-url>
—
List current configurations:
git config -l
—
Omit files from being checked for changes:
git update-index --assume-unchanged <path-to-file>
Be careful with this command. If you use it on files that you’ve made changes to, these files and changes will effectively become untracked and some operations might silently overwrite them or otherwise lead to the loss of changes. In other words, it is very easy to forget that you’ve set some files to be assumed unchanged and there are no warnings when these files are being affected by some processes. Your best bet is to write the files you’ve set to be assumed unchanged on a Post-It note and stick it on your computer monitor.
—
Undo the above:
git update-index --no-assume-unchanged <path-to-file>
—
List files marked with --assume-unchanged
:
git ls-files -v