Git – How to ignore file extension

Standard

Alot of times in a visual studio project you will want to ignore binary files types, such as .sln and .suo to make merging easier. This is how you do this:

touch .gitignore

git add .gitignore

git commit -m “added gitignore file”

Now you must edit the .gitignore file add the file extensions you want excluded

*.sln

*.suo

To stop tracking a file that is currently tracked, useĀ git rm –cached.

GIT Merge Error

Standard

If you are trying to merge a dev branch onto the master and get an error similar to the error below you might need to use rebase.

$ git merge dev
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

If you are trying to make master look like your dev branch then you need to use rebase like this:

git checkout master

git rebase dev

git push origin master

Git Cheat Sheet

Standard

Switch Between Dev and Prod Branches:

git checkout dev

git checkout master

Force a push (+)

git push origin +master

Reset back to a previous commit

git reset –hard commitID

Delete a local branch

git branch -D dev

Delete a Remote branch (make sure you don’t delete the main branch)

git push origin :dev