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

Bug Report

From
BSBenjamin Sandeen <benjaminsandeen2016@u.northwestern.edu>
Date
Apr 3, 2016, 00:25 UTC
Message-ID
<04bf01d18d3f$4ce38410$e6aa8c30$@u.northwestern.edu>

Today, I managed to create a duplicate branch in a git repository. While this may not be a bug per se, I do think that it is confusing and some way of preventing such issues in the future may be helpful.

I first cloned the repository:
$ git clone https://github.com/CodeForChicago/superclass.git
Then, I created a new branch (or so I thought):
$ git checkout -b lesson_page

However, this branch has already existed for about 4 weeks, without my knowledge. I proceeded to do some work on the files it contained, and when it came time to commit and push, and when I pushed, I got the following message:

To https://github.com/CodeForChicago/superclass.git
 ! [rejected]        lesson_page -> lesson_page (non-fast-forward)
error: failed to push some refs to '
https://github.com/CodeForChicago/superclass.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Given that I had believed that I had created the branch just a few hours prior and was the first to attempt to push to it, this error was consternating.

I may be wrong (I am aware that my understanding of git is limited), but I believe that the git checkout -b command is simply supposed to create a new branch and then switch to it (I'm not aware of any subtle behavior that goes on behind the scenes if the "new" branch that the user is attempting to create already exists). This is why I said it "may not be a bug per se". However, I expect most people who use git to expect this command to create a new branch and then switch to it (this is what most sources online will tell users to do to create a new branch), and as such, it would be extremely beneficial if git were to, at the very least, alert the user to the conflict in some way or another.

Thanks, Ben

Lead Consultant, Northwestern University Information Technology Research Assistant, Center for Interdisciplinary Exploration and Research in Astrophysics at Northwestern University Phsyics, Weinberg College of Arts and Sciences Computer Science, Weinberg College of Arts and Sciences Classics, Weinberg College of Arts and Sciences

Next: Eric N. Vander Weele
Message 1 of 3 in “Bug Report”
  1. Benjamin SandeenApr 3, 2016
  2. Eric N. Vander WeeleApr 3, 2016
  3. Jacob KellerApr 3, 2016

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.