public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail•com>
To: "Berat Özdemir" <Berat_Oezdemir@deichmann•com>,
	"git@vger•kernel.org" <git@vger•kernel.org>
Subject: Re: Bug/Weird behaviour with git pull
Date: Mon, 17 Apr 2023 06:49:59 -0600	[thread overview]
Message-ID: <643d407765bc7_751a29453@chronos.notmuch> (raw)
In-Reply-To: <AS8P194MB1575B12A6A11E3CBC6537C26E29C9@AS8P194MB1575.EURP194.PROD.OUTLOOK.COM>

Berat Özdemir wrote:
> 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

  parent reply	other threads:[~2023-04-17 12:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 10:34 Bug/Weird behaviour with git pull Berat Özdemir
2023-04-17 11:19 ` Kristoffer Haugsbakk
2023-04-17 11:57   ` AW: " Berat Özdemir
2023-04-17 12:49 ` Felipe Contreras [this message]
     [not found]   ` <AS8P194MB157593E9D310D6B03A1E0577E29C9@AS8P194MB1575.EURP194.PROD.OUTLOOK.COM>
     [not found]     ` <AS8P194MB157539251684168156C0EC99E29C9@AS8P194MB1575.EURP194.PROD.OUTLOOK.COM>
2023-04-17 16:21       ` Felipe Contreras
2023-04-17 17:08 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=643d407765bc7_751a29453@chronos.notmuch \
    --to=felipe.contreras@gmail$(echo .)com \
    --cc=Berat_Oezdemir@deichmann$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox