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

git push to a non-bare repository

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Mar 18, 2007, 17:31 UTC
Message-ID
<vpq648ye9w6.fsf@olympe.imag.fr>
Hi,

I have a repository with a working tree on a machine A, did a clone to another machine B and commited there locally.

I want my changes to get back into the first repository, so I did a "push". The new commit is in the history, I can see it with "git log", but the modifications are not in the working tree.

This time, it's OK: I didn't have any uncommited modifications on A, so I just did a "git reset --hard HEAD" there.

But if I had some uncommited changes, "git reset --hard HEAD" means data loss, which is precisely what I want to avoid by using a VCS. It seems a solution is to do:

$ git reset --soft <commit-id-before-the-push> $ git merge <commit-id-after-the-push>

But it means I have to remember <commit-id-before-the-push>.

I don't understand the design choice here: git had two options to avoid this scenario:

1) update the working tree while doing the push. That's feasible with
   good performance since git is present on the server, but leaves the
   problem of possible conflicts.
2) let git remember what the local tree points to (not just the branch
   name, but the commit id itself, stored in a place that "git push"
   won't modify). Then, provide me a way to "update" to the latest
   revision.

Fyi, bzr does this. Indeed, in bzr, a branch (let's say "repository" in the git vocabulary) with a working tree just means a working tree (AKA lightweight checkout) located in the same directory as a branch. The working tree knows which revision it corresponds to, and where to find its branch. There's a "bzr update" command to get my working tree to the head of the branch, keeping the uncommited changes.

I believe this idea is very much linked to the "Lightweight Checkout" idea (listed on the SoC ideas), since, in the case of multiple working directories sharing the same .git, you don't want a commit in one tree to affect the others.

So, did I miss something? Is there anything on the todo-list?
Thanks,
-- 
Matthieu
Next: Junio C Hamano
Message 1 of 27 in “git push to a non-bare repository”
  1. Matthieu MoyMar 18, 2007
  2. Junio C HamanoMar 18, 2007
  3. Sam VilainMar 18, 2007
  4. Jakub NarebskiMar 18, 2007
  5. Junio C HamanoMar 18, 2007
  6. Theodore TsoMar 19, 2007
  7. Junio C HamanoMar 19, 2007
  8. Shawn O. PearceMar 19, 2007
  9. Theodore TsoMar 19, 2007
  10. Shawn O. PearceMar 19, 2007
  11. Theodore TsoMar 19, 2007
  12. Shawn O. PearceMar 19, 2007
  13. Nicolas PitreMar 19, 2007
  14. Theodore TsoMar 19, 2007
  15. Junio C HamanoMar 19, 2007
  16. Nicolas PitreMar 19, 2007
  17. Nicolas PitreMar 19, 2007
  18. Sam VilainMar 19, 2007
  19. Junio C HamanoMar 20, 2007
  20. Junio C HamanoMar 20, 2007
  21. Theodore TsoMar 19, 2007
  22. Shawn O. PearceMar 19, 2007
  23. Junio C HamanoMar 19, 2007
  24. Matthieu MoyMar 19, 2007
  25. Jakub NarebskiMar 19, 2007
  26. Neil SchemenauerMar 21, 2007
  27. Sergio CallegariMar 19, 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.