Useful git stuff

cheatsheet
git
Author

Teresa Kubacka

Published

July 26, 2022

Because every now and then there is this thing you need to do with git, but because you do it not so often, you have to google it for like 30 sec. 

Useful git commands

Branches

To create a new completely empty branch:

git switch --orphan <new branch>
git commit --allow-empty -m "Initial commit on orphan branch"
git push -u origin <new branch>

src Article on branches

To pull a new branch from the server without touching the current branch: git fetch <remote_name> <branch_name> which in most cases is src

git fetch origin <branch_name>

Unstaging files

https://sethrobertson.github.io/GitFixUm/fixup.html

added but not committed

committed but not pushed

https://stackoverflow.com/a/15321456

git reset --soft HEAD^ 
git reset HEAD path/to/unwanted_file
git commit -c ORIG_HEAD 

The last command will recommit with the original commit message