User Tools

Site Tools


git_tips

On Windows

We are using Linux ending files (LF), be sure to disable automatic CRLF commits/imports on Windows with :

git config core.autocrlf false

see http://stackoverflow.com/a/1967986

Stash commits in one

Quick rebase + squash, using the 'staged' state:

git fetch upstream
git checkout my-branch
git merge upstream/master
git reset --soft upstream/master
git commit
git push origin my-branch -f

Alternative Method

git rebase -i HEAD~2
git push

Replace 2 with the number of commits backwards from where you are you want to include in your possible squashing. The -i flag allows you to pick what to do with each commit. If you've already pushed the commit to squash to the main repo, you shouldn't squash it in the first place, as it will mess up other people's local copies. If you've already pushed a squashed commit to a personal remote, you will have to force push the changes to your remote, as the commit has disappeared and a new one was added in its place.

Rebase instead of merge

Sometimes you know that your branch is behind, but your local commits don't conflict with the remote commits. You can then pass an argument to pull so it rebases instead of merging, avoiding an empty merge commit:

git pull --rebase

Skip CI build

If you've only changed a text file, or just a build irrelevant file, you can add [ci skip] to your commit message so Travis CI doesn't do a useless build.

git_tips.txt · Last modified: 2015/02/19 12:10 by freaktechnik