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

Re: Bug/Weird behaviour with git pull

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 17, 2023, 12:49 UTC
Message-ID
<643d407765bc7_751a29453@chronos.notmuch>
In-Reply-To
<AS8P194MB1575B12A6A11E3CBC6537C26E29C9@AS8P194MB1575.EURP194.PROD.OUTLOOK.COM>
Berat Özdemir wrote:
Show 15 quoted lines
> I stumbled on a weird behavior in git with the pull operation. 
> Imagine the following scenario:
> 
> We have a local and a remote repository, with the branches master, develop and f1. We
> 
> - cloned the remote repository. 
> - checked f1 out
> - checked develop out
> - run git merge f1. Merge was successful. 
> - Did not pushed
> - run git reset --hard origin/develop -> to undo the f1 merge into develop
> - run git pull origin f1
> 
> What did you expect to happen? (Expected behavior)
> I expected that "git pull origin f1" will just update the f1 branch (fetching and merging with origin/f1). In my case I expected nothing to happen since neither local f1 nor origin/f1 did changed while testing. Just develop changed locally, but it was resetted.
The first sentence of the documentation says:
  Incorporates changes from a remote repository into the current branch.
You are effectively merging origin/f1 into your current.

My recommendation to everyone is simply to not use `git pull`, as a lot of time (most of the time?) it doesn't do what the user wants. It's much better to just do `git fetch`+`git merge/rebase`.

Cheers.
-- 
Felipe Contreras
Previous: Berat ÖzdemirNext: Junio C Hamano
Message 4 of 6 in “Bug/Weird behaviour with git pull”
  1. Berat ÖzdemirApr 17, 2023
  2. Kristoffer HaugsbakkApr 17, 2023
  3. AW: Bug/Weird behaviour with git pullBerat Özdemir, Apr 17, 2023
  4. Felipe ContrerasApr 17, 2023
  5. Junio C HamanoApr 17, 2023
  6. Felipe ContrerasApr 17, 2023

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.