All of lore.kernel.org
 help / color / mirror / Atom feed
* Question with git push
@ 2008-12-23 16:59 Paul Vincent Craven
  2008-12-23 17:35 ` Peter Harris
  2008-12-23 17:37 ` demerphq
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Vincent Craven @ 2008-12-23 16:59 UTC (permalink / raw)
  To: git

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. Of course, then I would lose my changes
in the remote repository. What is the correct way of handling this?

A quick example:

mkdir -p RepositoryA/files RepositoryB
cd RepositoryA/files
echo "Test file" > test1.txt
git init
git add .
git commit -a -m "Test Commit 1"
cd ../../RepositoryB
git clone ../RepositoryA/files
cd files
# I want this change to go to RepositoryA
echo "More data" >> test1.txt
git add .
git commit -a -m "Test Commit 2"
git push ../../RepositoryA/files
cd ../../RepositoryA/files
echo "Test file" > test2.txt
git add .
# This commit reverts test1.txt to not have "More data"
git commit -a -m "Test Commit 3" # This reverts test1.txt to not
git diff master^ master

How do I change my commands so I keep the change I made in RepositoryB?

Thanks,

-- 
Paul Vincent Craven

--
Paul Vincent Craven
http://www.cravenfamily.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question with git push
  2008-12-23 16:59 Question with git push Paul Vincent Craven
@ 2008-12-23 17:35 ` Peter Harris
  2008-12-23 17:37 ` demerphq
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Harris @ 2008-12-23 17:35 UTC (permalink / raw)
  To: Paul Vincent Craven; +Cc: git

On Tue, Dec 23, 2008 at 11:59 AM, Paul Vincent Craven wrote:
> 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. Of course, then I would lose my changes
> in the remote repository. What is the correct way of handling this?

Pull from the other side, or push to a branch that you never check
out. Better yet, push to a bare (no work tree) repo you can pull from
both sides.

http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73

Peter Harris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question with git push
  2008-12-23 16:59 Question with git push Paul Vincent Craven
  2008-12-23 17:35 ` Peter Harris
@ 2008-12-23 17:37 ` demerphq
  1 sibling, 0 replies; 3+ messages in thread
From: demerphq @ 2008-12-23 17:37 UTC (permalink / raw)
  To: Paul Vincent Craven; +Cc: git

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/"

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-23 17:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-23 16:59 Question with git push Paul Vincent Craven
2008-12-23 17:35 ` Peter Harris
2008-12-23 17:37 ` demerphq

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.