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

Re: git pull/merge master on other branch

From
Johan Herland <johan@herland.net>
Date
May 9, 2008, 09:06 UTC
Message-ID
<200805091106.47447.johan@herland.net>
In-Reply-To
<g011ve$8ln$1@ger.gmane.org>
On Friday 09 May 2008, SungHyun Nam wrote:
Show 34 quoted lines
> Johan Herland wrote, at 5/9/2008 3:24 PM:
> > On Friday 09 May 2008, SungHyun Nam wrote:
> >> Hello,
> >>
> >> If I am on a branch (reguarly rebased), I don't want to switch to
> >> master branch, but merge origin into master.
> >> If I switch to master and pull and switch to branch, I have to
> >> rebuild almost of sources.
> >>
> >> How I can pull origin into master without switching to master
> >> branch?
> >
> > You can't; merging requires use of the working tree (to resolve
> > conflicts).
> >
> > However, what you can do is make a local clone of your project
> > (cheap, because it just hardlinks files from the original repo),
> > and checkout the master branch in the clone, perform the merge
> > (after having set up the same origin and retrieved its contents),
> > and then fetch (or push) the result back into the original repo
> > (remember: "fetch" instead of "pull", since the latter will
> > initiate a merge with your current branch).
>
> I tested and it seems work fine.
>
> $ mkdir repo; cd repo; git init; echo 'aaa' > a; git add .; git ci -m
> 'aaa'; cd ..
> $ git clone repo t; cd t; git co -b test; cd ..
> $ cd repo; echo 'bbb' >> a; git ci -m 'bbb' a; cd ..
> $ git clone t t2; cd t2; git remote add central ../repo; git pull
> central master; git push origin; cd ..
> $ cd t; git log; git log master; git rebase master
>
> Did I do correctly?
Looks good, AFAICS
Have fun! :)
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: SungHyun NamNext: Kevin Ballard
Message 4 of 9 in “git pull/merge master on other branch”
  1. SungHyun NamMay 9, 2008
  2. Johan HerlandMay 9, 2008
  3. SungHyun NamMay 9, 2008
  4. Johan HerlandMay 9, 2008
  5. Kevin BallardMay 9, 2008
  6. SungHyun NamMay 13, 2008
  7. Lars HjemliMay 13, 2008
  8. Brandon CaseyMay 13, 2008
  9. Kelvie WongMay 13, 2008

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.