# Move commits not in origin to a branch

3 messages from 2015-03-02 to 2015-03-02. Participants: shawn wilson, Michael J Gruber.
Thread: https://gitlist.dev/t/38678

## shawn wilson, 2015-03-02 13:25

Subject: Move commits not in origin to a branch
Message-ID: <CAH_OBicENXL967L4LubDzrqq2qxuZSqye3o6SPAq6oKM0=94Og@mail.gmail.com>
URL: https://gitlist.dev/e/CAH_OBicENXL967L4LubDzrqq2qxuZSqye3o6SPAq6oKM0%3D94Og%40mail.gmail.com

```
How do I move commits I haven't pushed into a new branch?

 % git log origin..master --pretty=format:'%h'
f7d3a19
1f186c9
66d99f6

Which I'd like to be in a new branch.

```

## Michael J Gruber, 2015-03-02 14:54

Subject: Re: Move commits not in origin to a branch
Message-ID: <54F479A1.300@drmicha.warpmail.net>
URL: https://gitlist.dev/e/54F479A1.300%40drmicha.warpmail.net
In-Reply-To: <CAH_OBicENXL967L4LubDzrqq2qxuZSqye3o6SPAq6oKM0=94Og@mail.gmail.com>

```
shawn wilson venit, vidit, dixit 02.03.2015 14:25:
> How do I move commits I haven't pushed into a new branch?
> 
>  % git log origin..master --pretty=format:'%h'
> f7d3a19
> 1f186c9
> 66d99f6
> 
> Which I'd like to be in a new branch.
> 

Do you want them to be on the new branch as they are, i.e. as commits
built on top of master? Then

git branch mybranch master

will create a new branch "mybranch" which contains those commits. If you
want to "remove" them from master, then

git checkout master # unless you are there already
git reset --keep origin/master

to "rewind" master to commit "origin/master".

Michael

```

## shawn wilson, 2015-03-02 15:43

Subject: Re: Move commits not in origin to a branch
Message-ID: <CAH_OBicLoSvnKx=2Y1oHCbXK+mUsKpg-TNwMfiaYs816kfsrwA@mail.gmail.com>
URL: https://gitlist.dev/e/CAH_OBicLoSvnKx%3D2Y1oHCbXK%2BmUsKpg-TNwMfiaYs816kfsrwA%40mail.gmail.com
In-Reply-To: <54F479A1.300@drmicha.warpmail.net>

```
On Mon, Mar 2, 2015 at 9:54 AM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:
> shawn wilson venit, vidit, dixit 02.03.2015 14:25:
>> How do I move commits I haven't pushed into a new branch?
>>
>>  % git log origin..master --pretty=format:'%h'
>> f7d3a19
>> 1f186c9
>> 66d99f6
>>
>> Which I'd like to be in a new branch.
>>
>
> Do you want them to be on the new branch as they are, i.e. as commits
> built on top of master? Then
>
> git branch mybranch master
>

Oh cool, I think that's what I wanted. I didn't realize it was that
easy - I said screw it and went and pushed them, but... for next time
(or I'll stop being stupid and work in a branch from now on).

Thanks

```
