Monday, June 29, 2015

Combine 2 commits into one and update pull request

Finally, I was able to combine 2 commits into 1 commit and update the pull request. This will save me lots of time instead of creating a new pull request everytime and re-do work.

First time:
git clone <my-clone-of-upstream-repo>
cd <upstream-repo>
git remote add upstream <upstream-repo>
git config --global push.default simple
When starting a new pull request:
git checkout -b <new-branch>
Make changes, commit and send pull request. 

When combining n commits:
git fetch upstream
git merge-base new-branch master => This will generate a commit hash
git rebase --interactive <commit hash>
Your text editor will open with a file that lists all the commits in new-branch, and in front of each commit is the word "pick". For every line except the first, you want to replace the word "pick" with the word "squash" or "fixup". Save this file. 
git rebase upstream/master
git push -f

Thursday, June 11, 2015

Start vim without .vim settings

In my .vim settings, I have audo indent and smart indent enabled. Sometimes when I'm copying code, this causes the code to completely go wonky.

So, to avoid this and just copy the code, I disable the vim settings and open the file using
vim -u NONE filename