git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Overwrite master

From
PHPeter Harris <git@peter.is-a-geek.org>
Date
Dec 2, 2008, 20:28 UTC
Message-ID
<eaa105840812021228v6f6e1252l5099f5dad325f99@mail.gmail.com>
In-Reply-To
<67A24C29-12A6-43B0-95D5-70910C5F8841@gmail.com>
On Tue, Dec 2, 2008 at 3:09 PM, Nicholas Wieland wrote:
Show 20 quoted lines
> 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
Previous: Nicholas Wieland
Message 4 of 4 in “Overwrite master”
  1. Nicholas WielandDec 2, 2008
  2. Peter HarrisDec 2, 2008
  3. Nicholas WielandDec 2, 2008
  4. Peter HarrisDec 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.