Your steps seem to imply he must use the same new_branch_name in 1) and in 
5). We can simplify this by avoiding renaming the master branch. I believe 
it is already tracking the github's origin.

So the steps can be rewritten like this:
1) git branch feature_branch_name
2) git stash
3) git fetch
4) git reset --hard origin/master
5) git push origin feature_branch_name
6) git co feature_branch_name
7) git stash pop

First we create a feature_branch_name on the tip of the local master, since 
it is ahead of the origin's one.
Then we stash the local changes and we reset the master branch to the same 
commit than the origin (3 & 4). The fetch is required when 
many developers push to the same remote. (Always use reset with care, since 
we can loose work. In doubt, create a temporarily branch as a safety net.)
Then we create the feature branch on the remote (5). It does not need to be 
the current branch.
Then we switch to the feature branch (6) and we recover the stashed 
modifications to continue the work on the feature branch. We can skip 5 if 
we do not want to publish it now and want to add more commits before. 

After that, we simply push to origin to update it with the new commits, ie: 
git push. If we commited on many tracked branches but want to push only 
one, we have to specify the branch name, ie: git push origin branch_name.

On Sunday, September 9, 2012 3:04:46 PM UTC-4, RubyRedRick wrote:
> On Sun, Sep 9, 2012 at 12:53 PM, Patrick < 
> <javascript:>>wrote:
>> Local Repo
>> 12 commits ahead of origin/master
>> How do I take those 12 commits and pull them off on a branch?
> I haven't tried this completely but since you haven't pushed the branch,I 
> think something like
> 1) git branch -m master new_branch_name
> 2) git fetch origin
> 3) git branch --track master origin/master
> 4) git checkout master
> 5) git branch -f new_branch_name master
> 6) git config branch.new_branch_namel.merge refs/heads/new_branch_name
> 7) git checkout new_branch_name
> 8) git push origin new_branch_name:refs/heads/new_branch_name
> First we give the local master branch the new name (1).
> Then we make sure we have the latest changes from master (2).
> Then we create a new local master branch which tracks the remote master 
> (3).
> We then checkout the master branch(4) to allow us to set the starting 
> point of the new branch(5)
> Next we tell the new branch to merge changes to the right branch on origin 
> (6) Note this remote branch won't exist yet.
> Finally we checkout the new local branch(7) and push it to the remote repo.
> -- 
> Rick DeNatale
> Google+: +Rick DeNatale <>
> Blog:
> Github:
> Twitter: @RickDeNatale
> WWR:
> LinkedIn:

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to