/ git

Useful Git Commands

I've been finding myself searching for a few useful Git commands lately that you'd think I'd know of by heart, but, you know, it hasn't happened for whatever reason. Here's a list of commands I keep going back to.

Clone a only specific branch

git clone -b <branch> <remote_repo>

Get a local working copy of a remote branch

git branch -a
git checkout -b branchname origin/branchname

Stage deleted files for commit

git add -u

Untrack files without deleting them

echo "*.config">>.gitignore
git rm --cached "*.config"
git add .
git commit -m "Ignoring and deleting config files."
git push origin