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

Re: pushing changes to a remote branch

From
Jeff King <peff@peff.net>
Date
Jul 10, 2007, 17:34 UTC
Message-ID
<20070710173401.GB5032@sigill.intra.peff.net>
In-Reply-To
<20070710143614.GA29681@piper.oerlikon.madduck.net>
On Tue, Jul 10, 2007 at 04:36:14PM +0200, martin f krafft wrote:
Show 10 quoted lines
>   git checkout origin/vim
>     Note: moving to "origin/vim" which isn't a local branch
>   echo change > newfile; git add newfile
>   git commit -m'make change'
>     Created commit 64b8b2e: make change
>      1 files changed, 1 insertions(+), 0 deletions(-)
>       create mode 100644 newfile
>   
> If I now checkout master and then return to origin/vim, the commit
> is gone.

That's because 'origin/vim' is a tracking branch for the remote; it's where you store the information "here's what the remote 'origin' thinks is in the branch 'vim'." That's why you get the "note" warning above.

If you want to make changes, you should make a local branch starting from that point:

  git-checkout -b vim origin/vim
  # hack hack hack
  git-commit -m changes
> Much more, however, I am interested how I am supposed to push
> commits back to select remote branches.

Now when you issue a git-push, you will push _your_ 'vim' branch to the remote's 'vim' branch. Before, you didn't _have_ a vim branch, so nothing was pushed.

So the key thing you are missing in all of this is that you shouldn't be doing _anything_ with branches in origin/* (which are, of course, actually refs/remotes/origin/*) except for read-only operations (like diffing against them, merging with them, etc). They are purely for tracking the remote's branches.

-Peff
Previous: martin f krafftNext: Brian Gernhardt
Message 2 of 10 in “pushing changes to a remote branch”
  1. martin f krafftJul 10, 2007
  2. Jeff KingJul 10, 2007
  3. Brian GernhardtJul 10, 2007
  4. Jeff KingJul 10, 2007
  5. Sean KelleyJul 11, 2007
  6. Jan HudecJul 11, 2007
  7. Jan HudecJul 11, 2007
  8. Junio C HamanoJul 11, 2007
  9. Jan HudecJul 14, 2007
  10. Jan HudecJul 11, 2007

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.