# Overwrite master

4 messages from 2008-12-02 to 2008-12-02. Participants: Nicholas Wieland, Peter Harris.
Thread: https://gitlist.dev/t/16560

## Nicholas Wieland, 2008-12-02 16:10

Subject: Overwrite master
Message-ID: <D1AC0A41-E89A-4B53-A449-DA9C4422998E@zooppa.com>
URL: https://gitlist.dev/e/D1AC0A41-E89A-4B53-A449-DA9C4422998E%40zooppa.com

```
Hi *,
I need to overwrite my master branch with another branch. I've already  
created a backup branch of my master.
I tried a merge but it's just too big to handle, and I don't really  
care about what's in my master now.
The reason I want to do something like this is to be able to branch  
directly from my master in the future and merge back smaller branches  
(basically what I didn't do this time ...) instead of trying to merge  
back a huge one. This time I've used git like I've used svn, my bad,  
very stupid thing ...
Hope my question is clear.

TIA,
   ngw

```

## Peter Harris, 2008-12-02 16:32

Subject: Re: Overwrite master
Message-ID: <eaa105840812020832p395ecefdq57e62f95182a3557@mail.gmail.com>
URL: https://gitlist.dev/e/eaa105840812020832p395ecefdq57e62f95182a3557%40mail.gmail.com
In-Reply-To: <D1AC0A41-E89A-4B53-A449-DA9C4422998E@zooppa.com>

```
On Tue, Dec 2, 2008 at 11:10 AM, Nicholas Wieland wrote:
> Hi *,
> I need to overwrite my master branch with another branch. I've already
> created a backup branch of my master.

While on master,
"git reset --hard <newbranch>"

Or while on a different branch,
git branch -D master
git branch master <newbranch>

Peter Harris

```

## Nicholas Wieland, 2008-12-02 20:09

Subject: Re: Overwrite master
Message-ID: <67A24C29-12A6-43B0-95D5-70910C5F8841@gmail.com>
URL: https://gitlist.dev/e/67A24C29-12A6-43B0-95D5-70910C5F8841%40gmail.com
In-Reply-To: <eaa105840812020832p395ecefdq57e62f95182a3557@mail.gmail.com>

```
Il giorno 02/dic/08, alle ore 17:32, Peter Harris ha scritto:

> On Tue, Dec 2, 2008 at 11:10 AM, Nicholas Wieland wrote:
>> Hi *,
>> I need to overwrite my master branch with another branch. I've  
>> already
>> created a backup branch of my master.
>
> While on master,
> "git reset --hard <newbranch>"
>
> Or while on a different branch,
> git branch -D master
> git branch master <newbranch>

That's what I tried.
Unfortunately I don't know where to go after:

ngw@slicingupeyeballs ~/zooppa$ git commit
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 444 and 25 different commit(s) each, respectively.
#
nothing to commit (working directory clean)

Do I have to push ? If I pull it tries to merge ...


Thanks a lot for your time,
   ngw


```

## Peter Harris, 2008-12-02 20:28

Subject: Re: Overwrite master
Message-ID: <eaa105840812021228v6f6e1252l5099f5dad325f99@mail.gmail.com>
URL: https://gitlist.dev/e/eaa105840812021228v6f6e1252l5099f5dad325f99%40mail.gmail.com
In-Reply-To: <67A24C29-12A6-43B0-95D5-70910C5F8841@gmail.com>

```
On Tue, Dec 2, 2008 at 3:09 PM, Nicholas Wieland wrote:
> Il giorno 02/dic/08, alle ore 17:32, Peter Harris ha scritto:
>
>> On Tue, Dec 2, 2008 at 11:10 AM, Nicholas Wieland wrote:
>>>
>>> Hi *,
>>> I need to overwrite my master branch with another branch. I've already
>>> created a backup branch of my master.
>>
>> While on master,
>> "git reset --hard <newbranch>"
>
> That's what I tried.
> Unfortunately I don't know where to go after:
>
> ngw@slicingupeyeballs ~/zooppa$ git commit
> # On branch master
> # Your branch and 'origin/master' have diverged,
> # and have 444 and 25 different commit(s) each, respectively.
> #
> nothing to commit (working directory clean)

That means your tracking branch is different from your local branch, by a lot.

> Do I have to push ? If I pull it tries to merge ...

If you push, it will be denied (non-fast-forward).

If you force push, your state will be as you expect. Be aware that
you're creating trouble for everyone else who uses 'origin' if you
force push. Also be aware that you will be undoing any changes that
anyone else has pushed to origin in the mean time.

Basically, history is history. If you don't want to cause problems for
the other users of 'origin', you may have to live with history as it
is. You won't be able to overwrite master, although you will probably
try to be more careful in the future.

Peter Harris

```
