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

Re: pushing changes to a remote branch

From
SKSean Kelley <svk.sweng@gmail.com>
Date
Jul 11, 2007, 03:44 UTC
Message-ID
<a2e879e50707102044l864b9dcre5b6fa5893ff4803@mail.gmail.com>
In-Reply-To
<844FC382-DFB3-4762-93C2-6512612136AC@silverinsanity.com>
Hi,
On 7/10/07, Brian Gernhardt <benji@silverinsanity.com> wrote:
Show 41 quoted lines
>
> On Jul 10, 2007, at 1:34 PM, Jeff King wrote:
>
> > On Tue, Jul 10, 2007 at 04:36:14PM +0200, martin f krafft wrote:
> >
> >>   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
>
> Indeed, in master, git outputs a hint to that when you checkout the
> remote branch.
>
>    $ git checkout origin/master
>    Note: moving to "origin/master" which isn't a local branch
>    If you want to create a new branch from this checkout, you may do so
>    (now or later) by using -b with the checkout command again. Example:
>      git checkout -b <new_branch_name>
>    HEAD is now at f4855d4... 1
>
> Perhaps git-commit should also also output a warning?  "Commit made
> on detached HEAD.  Use "git branch <new_branch_name>" to save your
> commit"?  That's bad wording, but the idea is there.

If you then do a push from that new_branch_name will it create a new branch on the remote? I am struggling with just being able to add a remote. Create a local branch that maps to the remote. Then committing and pushing changes to the remote - all without creating a new branch on the remote.

Sean
Show 7 quoted lines
>
> ~~ Brian
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Previous: Jeff KingNext: Jan Hudec
Message 5 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.