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

Re: Question with git push

From
Ddemerphq <demerphq@gmail.com>
Date
Dec 23, 2008, 17:37 UTC
Message-ID
<9b18b3110812230937p3c53f778h508746a3df72610e@mail.gmail.com>
In-Reply-To
<5591393c0812230859n3b50b1f9k36153f40dd75ff57@mail.gmail.com>
2008/12/23 Paul Vincent Craven <paul@cravenfamily.com>:
> If I do a 'git push' to another repository, my changes are reverted
> the next time that repository is updated, unless I do a hard reset on
> the remote repository first.
Or just git checkout -f
> Of course, then I would lose my changes
> in the remote repository. What is the correct way of handling this?

I think the general practice is not to push to non-bare repositories unless you and the owner of the repository can coordinate things. This either means you push and then tell them, or they set up a post-receive hook (and understand the consequences of doing so). Of course often you are both of these people and coordination is easy.

The post-receive hook would go in .git/hooks and would effectively execute:
  git checkout -f

on push. However this also means that the working directory will be unilaterally updated every time someone pushes. Not something you want to do in a truely shared non-bare repo. Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
Previous: Peter Harris
Message 3 of 3 in “Question with git push”
  1. Paul Vincent CravenDec 23, 2008
  2. Peter HarrisDec 23, 2008
  3. demerphqDec 23, 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.