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

Re: Why is there no force pull?

From
Torsten Bögershausen <tboegi@web.de>
Date
Jun 10, 2018, 16:11 UTC
Message-ID
<20180610161153.GA27202@atze2.lan>
In-Reply-To
<20180609190154.yl4ig6dxfihgm5qi@christoph-lap>
On Sat, Jun 09, 2018 at 09:01:54PM +0200, Christoph Böhmwalder wrote:
Show 11 quoted lines
> Hi,
> 
> Since this is a use case that actually comes up quite often in
> day-to-day use, especially among git beginners, I was wondering: is
> there a specific reason why a command like "fetch changes from remote,
> overwriting everything in my current working directory including all
> commits I've made" doesn't exist? Now, I'm quite aware that something
> like
> 
>     $ git fetch origin/branch
>     $ git reset --hard origin/branch

This is not exactly what you askeded for, but I tend not to recommend people using "git reset --hard" at all. Either use a "stash", just in case.

Or, in your case: $ git fetch origin && git checkout origin/branch

This will put your working tree onto origin/branch.

As a bonus, in case that you have done commits, which are now no longer visible, "git reflog" is typically able to find them.

Previous: Ævar Arnfjörð Bjarmason
Message 5 of 5 in “Why is there no force pull?”
  1. Christoph BöhmwalderJun 9, 2018
  2. Elijah NewrenJun 9, 2018
  3. Christoph BöhmwalderJun 9, 2018
  4. Ævar Arnfjörð BjarmasonJun 9, 2018
  5. Torsten BögershausenJun 10, 2018

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.