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

Bug/Weird behaviour with git pull

From
BÖBerat Özdemir <berat_oezdemir@deichmann.com>
Date
Apr 17, 2023, 10:34 UTC
Message-ID
<AS8P194MB1575B12A6A11E3CBC6537C26E29C9@AS8P194MB1575.EURP194.PROD.OUTLOOK.COM>
Hi there,

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.

What happened instead? (Actual behavior) "git pull origin f1" created a new commit, which was the previously resetted merge into the develop branch.

What's different between what you expected and what actually happened?
I expected nothing to happen  (or if remote f1 changed, that those changes would be present locally) but I got the previously resetted merge into develop redone 
Anything else you want to add:

We use git with one remote repository with a master branch, a develop branch and a lot of feature branches. I was about to write a script, which determines candidate feature-branches, which should be automatically merged into the develop branch.

Our merge-workflow is as follows:
1. Update local repository (pull develop, pull the feature-branch which should be merged)
2. Merge
3. Push
While testing my script, I did not pushed at all, since I didn't want to publish some weird testing stuff to the remote. Therefore every merge I did was locally.
What did you do before the bug happened? (Steps to reproduce your issue)
I pulled develop and feature f1. Then I switched to the develop branch and run "git merge --no-ff f1". The merge was successful. Now I changed my script (git-irrelevant things, like transitioning the corresponding ticket) and wanted to test the script again. To do this I wanted to undo the merge and did a hard reset on the local develop branch to the origin/develop commit. Everything was okay until I ran the script again - it reported that there was already a merge. I checked the git tree - and there it was. I repeated the process with resetting the develop branch and explicitly commented the "git merge" part out of my script. But after running the script, the merge was there again. After trying around I found out, that the "git pull origin f1" command redoes the resetted merge into develop. On the remote nothing changed while I was testing - so I don't get why git pull does anything at all.
 
I thought, the pull command fetches new commits from the remote and merges tracked remote branch into the local tracking branch.

[System Info] git version: git version 2.38.1.windows.1 cpu: x86_64 built from commit: b85c8f604d375d4d773a36842964e8a7ec056aae sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon uname: Windows 10.0 19045 compiler info: gnuc: 12.2 libc info: no libc information available $SHELL (typically, interactive shell): <unset>

Mit freundlichen Grüßen
​Kind regards
Berat Özdemir
IT Software Entwicklung
Phone:+49 201 8676  14402
Berat_Oezdemir@deichmann.com
www.deichmann.com
​Deichmann SE, Deichmannweg 9, D-45359 Essen
 
Sitz der Gesellschaft: Essen, Registergericht Essen HRB 21020, USt.-ID-Nr.: DE 119 663 402
Vorsitzender des Verwaltungsrats und der geschäftsführenden Direktoren: Heinrich Otto Deichmann
Geschäftsführende Direktoren:
Alexander Bellin * Samuel Deichmann * Martin Fischer * Dr. Lars Jendrian * Manfred Kroneder
Next: Kristoffer Haugsbakk
Message 1 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.