Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Thursday, June 8, 2017

Sync up your fork with upstream without creating merge commit

From your fork on the local machine

cd  <fork>
git checkout master
git fetch upstream
git rebase upstream/master
git push -f

This will make your fork match up with what's upstream

 
 

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

Wednesday, April 15, 2015

Syncing a fork of github

I use github for my work and have a fork of some repositories. When I send a pull request, often I have issues with my fork being out of sync with the main repository.

Today, I synced up my fork without any issues. Here's how I did it.

Go to folder which contains the clone of of your fork.

git remote add upstream https://github.com/upstreamreponame/repo.git
git fetch upstream
git checkout master (to make sure you're on master)

If you want to make sure these changes don't show up as a checkin on ur fork:

git merge upstream/master

This worked great for me!


References:
Syncing a fork
How to update GitHub forked respository
Updating a fork directly from github