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

Re: git loses commits on git pull --rebase with Dictator and Lieutenants Workflow

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 29, 2015, 19:31 UTC
Message-ID
<xmqqlhkle64d.fsf@gitster.dls.corp.google.com>
In-Reply-To
<loom.20150128T203924-608@post.gmane.org>
Dick <dick@mrns.nl> writes:
Show 12 quoted lines
> rm -rf left/ right/ right.git/
> git init left
> cd left/
> echo "hello world" > test.txt
> git add test.txt 
> git commit -m .
> cd ..
> git clone --bare left right.git
> git clone right.git/ right
> cd right
> git remote set-url origin ../left
> git remote set-url origin --push ../right.git

This is not using "origin" and set-url correctly. Even though you can use physically different URLs for fetching from and pushing into, the named repository 'origin' is still conceptually the same repository. You use this mechanism when you want to fetch over the public git:// protocol (which is lighter-weight) while pushing into the same repository over ssh:// protocol (which may be heavier and requires authentication). The important part of the equation is that the data should go to and come from the same place. What you pushed to 'origin', if you fetch from 'origin' again, should come back to you.

And that is not what your two calls to set-url are doing.
In a triangular workflow to fetch from somewhere while pushing into
somewhere else, you are using _two_ different repositories: your
upstream's repository you fetch from, and your own repository you
push to publish your result.  So you would use _two_ remotes, not a
single 'origin'.
	
The 'right' person, who follows the 'left' developer who publishes
the more authoritative work in 'left.git' for you and others to
fetch from, and publishes his work to 'right.git' to ask 'left' to
pull, would do something like:
	git init --bare right.git
	git clone left right
	cd right
        git remote add mine ../right.git
        git config remote.pushDefault mine
        git push --all;# to publish to ../right.git
to set things up.  Then
	edit && git commit && git other-commands && ...
	git push ;# updates ../right.git
to publish his work.  Updating from 'left' would go like this:
	# pretend 'left' did something
	( cd ../left && git commit --allow-empty -m empty )
	git pull ;# or 'git pull --rebase'
Previous: Chris PackhamNext: Dick
Message 4 of 7 in “git loses commits on git pull --rebase with Dictator and Lieutenants Workflow”
  1. DickJan 28, 2015
  2. Chris PackhamJan 29, 2015
  3. Chris PackhamJan 29, 2015
  4. Junio C HamanoJan 29, 2015
  5. DickJan 29, 2015
  6. Re* git loses commits on git pull --rebase with Dictator and Lieutenants WorkflowJunio C Hamano, Jan 29, 2015
  7. Eric SunshineJan 29, 2015

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.