My Most Used Git Bash Commands

My personal documentation of the git commands I use the most for game development. Around 95 percent of the stuff I do with git, are done with these commands.

I am not a git expert, so this is not a tutorial, just a series of commands I use frequently. I am sure there are plenty ways to do the stuff safer, or more efficient.

Obvious ones:

git status git add . git commit -m “comment” git pull git push 

To get rid of local changed checkout for changed files and rm/ clean files that were added and are untracked:

git checkout . 

If you added files (staged) to commit, and would like to undo that, you can use reset:

git reset <filepath>

Resetting to older commits to clean up messed up merge:

git reflog

choose the commit I want and then:

git reset --hard [commit I want to rest to] 

And getting rid of unwanted untracked files, first a dry run with -n to know what I will get rid of, then -f to actually do it:

git clean -n git clean -f

pulling with merge strategy:

git pull -X theirs/ours

If you are already in merge conflict and want to take theirs or yours on a file:

git checkout --theirs path/to/file

Branching to development and merging it back to master:

First create a development branch:

git checkout -b dev

Doing whatever I want, commiting and then pushing it. Instead of orgin master, I would be pushing origin dev:

git push origin dev

Once I am done with testing the feature and ready to merge it with master, checkout master and then merge:

git checkout master
git merge dev

Once I am sure my changes are set in stone, deleting the dev branch locally and remote:

git branch -d dev
git branch -d -r origin/dev

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store