* git pull/merge master on other branch
@ 2008-05-09 5:26 SungHyun Nam
2008-05-09 6:24 ` Johan Herland
2008-05-13 3:12 ` Kelvie Wong
0 siblings, 2 replies; 9+ messages in thread
From: SungHyun Nam @ 2008-05-09 5:26 UTC (permalink / raw)
To: git
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?
Thanks,
namsh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 5:26 git pull/merge master on other branch SungHyun Nam
@ 2008-05-09 6:24 ` Johan Herland
2008-05-09 8:28 ` SungHyun Nam
2008-05-09 17:16 ` Kevin Ballard
2008-05-13 3:12 ` Kelvie Wong
1 sibling, 2 replies; 9+ messages in thread
From: Johan Herland @ 2008-05-09 6:24 UTC (permalink / raw)
To: SungHyun Nam; +Cc: git
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).
Have fun! :)
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 6:24 ` Johan Herland
@ 2008-05-09 8:28 ` SungHyun Nam
2008-05-09 9:06 ` Johan Herland
2008-05-09 17:16 ` Kevin Ballard
1 sibling, 1 reply; 9+ messages in thread
From: SungHyun Nam @ 2008-05-09 8:28 UTC (permalink / raw)
To: git
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?
Thanks,
namsh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 8:28 ` SungHyun Nam
@ 2008-05-09 9:06 ` Johan Herland
0 siblings, 0 replies; 9+ messages in thread
From: Johan Herland @ 2008-05-09 9:06 UTC (permalink / raw)
To: SungHyun Nam; +Cc: git
On Friday 09 May 2008, SungHyun Nam wrote:
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 6:24 ` Johan Herland
2008-05-09 8:28 ` SungHyun Nam
@ 2008-05-09 17:16 ` Kevin Ballard
2008-05-13 2:22 ` SungHyun Nam
2008-05-13 17:24 ` Brandon Casey
1 sibling, 2 replies; 9+ messages in thread
From: Kevin Ballard @ 2008-05-09 17:16 UTC (permalink / raw)
To: Johan Herland; +Cc: SungHyun Nam, git
On May 9, 2008, at 1:24 AM, Johan Herland wrote:
> 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).
If you know the pull will just be a fast-foward, then you can do
something like
git fetch origin && git update-ref master origin/master
-Kevin Ballard
--
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 17:16 ` Kevin Ballard
@ 2008-05-13 2:22 ` SungHyun Nam
2008-05-13 16:08 ` Lars Hjemli
2008-05-13 17:24 ` Brandon Casey
1 sibling, 1 reply; 9+ messages in thread
From: SungHyun Nam @ 2008-05-13 2:22 UTC (permalink / raw)
To: git
Kevin Ballard wrote, at 5/10/2008 2:16 AM:
> On May 9, 2008, at 1:24 AM, Johan Herland wrote:
>
>> 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).
>
>
> If you know the pull will just be a fast-foward, then you can do
> something like
>
> git fetch origin && git update-ref master origin/master
It seems it worked, but I see a warning message "refname 'master'
is ambiguous." Can I fix this warning message?
[test] ~/tmp/t[52]$ git fetch origin
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /d/user/namsh/tmp/repo/
6e13bb5..8d1c620 master -> origin/master
[test] ~/tmp/t[53]$ git update-ref master origin/master
[test] ~/tmp/t[69]$ git log master
warning: refname 'master' is ambiguous.
commit a358783b78facffb9a8f69d2189aa716495d95ba
..
[test] ~/tmp/t[54]$ git rebase master
warning: refname 'master' is ambiguous.
warning: refname 'master' is ambiguous.
First, rewinding head to replay your work on top of it...
Fast-forwarded test to master.
regards,
namsh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 5:26 git pull/merge master on other branch SungHyun Nam
2008-05-09 6:24 ` Johan Herland
@ 2008-05-13 3:12 ` Kelvie Wong
1 sibling, 0 replies; 9+ messages in thread
From: Kelvie Wong @ 2008-05-13 3:12 UTC (permalink / raw)
To: SungHyun Nam; +Cc: git
On 5/8/08, SungHyun Nam <goweol@gmail.com> wrote:
> How I can pull origin into master without switching to master
> branch?
>
> Thanks,
> namsh
>
To do this, one would use the "push" subcommand, with "." as the repository.
git push . origin/master:master
I could have sworn I answered someone the exact same thing a while ago...
--
Kelvie Wong
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-13 2:22 ` SungHyun Nam
@ 2008-05-13 16:08 ` Lars Hjemli
0 siblings, 0 replies; 9+ messages in thread
From: Lars Hjemli @ 2008-05-13 16:08 UTC (permalink / raw)
To: SungHyun Nam; +Cc: git, Kevin Ballard, Johan Herland
On Tue, May 13, 2008 at 4:22 AM, SungHyun Nam <goweol@gmail.com> wrote:
> Kevin Ballard wrote, at 5/10/2008 2:16 AM:
>
> > If you know the pull will just be a fast-foward, then you can do
> > something like
> >
> > git fetch origin && git update-ref master origin/master
I belive that should be `update-ref refs/heads/master origin/master`,
otherwise you'll get this error:
> It seems it worked, but I see a warning message "refname 'master'
> is ambiguous." Can I fix this warning message?
Try `rm .git/master`.
--
larsh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git pull/merge master on other branch
2008-05-09 17:16 ` Kevin Ballard
2008-05-13 2:22 ` SungHyun Nam
@ 2008-05-13 17:24 ` Brandon Casey
1 sibling, 0 replies; 9+ messages in thread
From: Brandon Casey @ 2008-05-13 17:24 UTC (permalink / raw)
To: Kevin Ballard; +Cc: Johan Herland, SungHyun Nam, git
Kevin Ballard wrote:
> On May 9, 2008, at 1:24 AM, Johan Herland wrote:
>
>> 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).
>
>
> If you know the pull will just be a fast-foward, then you can do
> something like
>
> git fetch origin && git update-ref master origin/master
I recommend against using update-ref...
and instead suggest using fetch to do all of the work.
Some variation of:
git fetch origin master:master
This will only fast-forward the master branch based on the remote origin's
master branch. update-ref will blindly overwrite the master ref, if you make
a mistake and its not a fast-forward, you just lost some commits.
The above doesn't update your remotes though, maybe the following would be
correct, but I haven't tried it.
git fetch origin && git fetch . remotes/origin/master:master
Also, I'm surprised no one mentioned the git-new-workdir script in the
contrib directory. It allows you to have multiple work directories
which share and update a single repository.
You could
git-new-workdir <path_to_repo> <path_to_newworkdir> master
cd <path_to_newworkdir>
git pull
-brandon
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-05-13 17:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-09 5:26 git pull/merge master on other branch SungHyun Nam
2008-05-09 6:24 ` Johan Herland
2008-05-09 8:28 ` SungHyun Nam
2008-05-09 9:06 ` Johan Herland
2008-05-09 17:16 ` Kevin Ballard
2008-05-13 2:22 ` SungHyun Nam
2008-05-13 16:08 ` Lars Hjemli
2008-05-13 17:24 ` Brandon Casey
2008-05-13 3:12 ` Kelvie Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).