Should I be creating a new fork or branch on GitHub for new patches?
#1
I've started using GitHub finally and Pull Requests for submitting patches, but I've ran into a little snag and am curious to know what is the proper way of fixing it.

I made a fork of the XBMC repo on GitHub and created two patches on the master branch, both patches consisting of several commits. I just submitted a Pull Request for the first patch, selecting the first three commits as the commit range for the Pull Request. When I tried to create the second Pull Request, I realized that it would include the other patch as well, since Pull Request are for a range of commits beginning with when I forked the repo. So I'm assuming I have to separate things and work separate on these two patches. The question I have is, should I be creating a separate fork of the XBMC repo for each patch I'm working on, or is the proper way to just create a new branch?

Thanks,
Harry
Reply
#2
Create a branch per pull is the best way, yup.

If you have it already in master and you want to pull say the top 4 commits off into a separate branch, then a simple way is:

git checkout master
git checkout -b my_new_branch master
git checkout master
git reset HEAD~4

If it's k commits, then git reset HEAD~k will do it. You can also just git reset <hash of commit> to go back to a specific one. This will put you back in history to before that commit, but will still leave your changes in place. To get rid of them, use git reset --hard HEAD after the above, or you can slot the --hard into the previous command - use wisely!

The git reset trick is a nice way to split up commits as well - eg you commit 3 separate changes all in one block, then git reset HEAD~1 will get you to the previous state, with all your changes unstaged. Then you can git add -p <files> and add just the bits you want, commit, rinse, repeat.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
And to push that branch up to github it's just:

git push <your repo name on github> <branchname>:<remote_branchname>

You can leave off :<remote_branchname> if it's the same as branchname Smile

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
Awesome info. Thanks. I'm finally starting to not hate git Smile Smile

Harry
Reply
#5
Beware - very soon you'll start loving it Wink
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply

Logout Mark Read Team Forum Stats Members Help
Should I be creating a new fork or branch on GitHub for new patches?0