git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to update? (git Changed but not updated)
@ 2009-02-21 21:23 Reto S. News
  2009-02-22  1:10 ` Sitaram Chamarty
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Reto S. News @ 2009-02-21 21:23 UTC (permalink / raw)
  To: git

Beginner question: "How to update the pushed changes on the master?"

As a proof of concept to switch from CVS to git I prepared an
environment on two servers. I call the one "Slave" and "Master"
the other. Almost everything is working besides a silly
"cvs update" functionality I couldn't still find out after hours.

On Slave Host (a Developer that receives a working copy of a project):

$ git clone git://master.example.net/test myrepo
$ cd myrepo   # ... here I see all received files from the master
$ Changing file "foo.txt"
$ git add .   # ... for whatever reason this is necessary
$ git commit -m 'I changed this file'
$ git push

On Master Host (master.example.net):

# git status # Shows me correctly foo.txt has been changed by the"Slave"
# git show   # Shows me even the made changes in a diff style!


Now I have to update the fresh content produced by the "Slave". As an
ugly work-around, I'm currently cloning it again from localhost :-|

Any suggestions are very appreciated.

--reto

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

* Re: How to update? (git Changed but not updated)
  2009-02-21 21:23 How to update? (git Changed but not updated) Reto S. News
@ 2009-02-22  1:10 ` Sitaram Chamarty
  2009-02-22  1:32 ` Rainer Blome
  2009-02-22 10:07 ` Reto Schär
  2 siblings, 0 replies; 4+ messages in thread
From: Sitaram Chamarty @ 2009-02-22  1:10 UTC (permalink / raw)
  To: git

On 2009-02-21, Reto S. News <retoh@dplanet.ch> wrote:
> Beginner question: "How to update the pushed changes on the master?"
>
> On Slave Host (a Developer that receives a working copy of a project):
>
> $ git clone git://master.example.net/test myrepo
> $ cd myrepo   # ... here I see all received files from the master
> $ Changing file "foo.txt"
> $ git add .   # ... for whatever reason this is necessary
> $ git commit -m 'I changed this file'
> $ git push
>
> On Master Host (master.example.net):
>
> # git status # Shows me correctly foo.txt has been changed by the"Slave"
> # git show   # Shows me even the made changes in a diff style!

I'll bet the changes shown are 'reversed'...

> Now I have to update the fresh content produced by the "Slave". As an
> ugly work-around, I'm currently cloning it again from localhost :-|
>
> Any suggestions are very appreciated.

Your master is a non-bare repo.  Try
http://git.or.cz/gitwiki/GitFaq#non-bare .

I also wrote up a much more detailed description of this at
http://sitaramc.github.com/concepts-and-tips/0-terminology.html#a5
-- I hope it helps you.

Regards,

Sitaram

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

* Re: How to update? (git Changed but not updated)
  2009-02-21 21:23 How to update? (git Changed but not updated) Reto S. News
  2009-02-22  1:10 ` Sitaram Chamarty
@ 2009-02-22  1:32 ` Rainer Blome
  2009-02-22 10:07 ` Reto Schär
  2 siblings, 0 replies; 4+ messages in thread
From: Rainer Blome @ 2009-02-22  1:32 UTC (permalink / raw)
  To: Reto S. News; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2361 bytes --]

Reto S. News wrote:
> Beginner question: "How to update the pushed changes on the master?"

> # git status # Shows me correctly foo.txt has been changed by the"Slave"

No, it shows that the work tree has been left behind with respect to the 
head of master.

Fix this using git checkout master and git reset --hard.

> # git show   # Shows me even the made changes in a diff style!

But probably the wrong way around, showing added lines as removed?


Freshman answer:
Here's what I am doing.

The attached script mygit-test.sh is a simple test of the below work 
flow, with three repositories a (origin), and clones b and c.

Let's calls the "Master" server "Shared", to avoid confusion with any 
"master" branch.

On Shared, do not work in the master branch.
Instead, work in a dedicated local branch, for example 
"central-development".

# Only needed if your working directory and index are not clean:
git stash

git checkout master
git checkout -b central-development

# Only needed if you had to stash above:
git stash apply
# You can now commit any changes
# Once you've safely commited the changes, use: git stash clear


On Slave, do not work in the master branch as well.
Instead, work in a dedicated local branch, for example "slave".

git checkout -b master origin/master  # Ensure a local copy of master exists
git pull origin master # Ensure the new branch is up to date
git checkout -b slave  # Create the local development branch

# Now edit, commit, edit, commit, ...
# Once you want to publish your changes:

# Update local copy of master:
git pull --rebase origin master

# LOOP:
# Merge your changes on top of new master, staying on slave:
git rebase master slave
# Test and review the merged code on slave.

# Update local copy of master, again,
# to make sure it has not changed in the meantime:
git pull --rebase origin master
# If it changed, go to LOOP, otherwise continue below.

# Update local copy of master (this is now fast-forward)
git rebase slave master
# Send changes to master on Shared
git push origin master
# Leave master
git checkout slave

On Shared:
# Update development with respect to changes on master
git rebase master development


Complex?  Yes.
Can it be simplified?  I hope so.

I have written a script that helps to use the work flow described here.
If anyone is interested, please comment.

Good luck, Rainer


[-- Attachment #2: mygit-test.sh --]
[-- Type: application/x-sh, Size: 2236 bytes --]

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

* Re: How to update? (git Changed but not updated)
  2009-02-21 21:23 How to update? (git Changed but not updated) Reto S. News
  2009-02-22  1:10 ` Sitaram Chamarty
  2009-02-22  1:32 ` Rainer Blome
@ 2009-02-22 10:07 ` Reto Schär
  2 siblings, 0 replies; 4+ messages in thread
From: Reto Schär @ 2009-02-22 10:07 UTC (permalink / raw)
  To: git

Sorry. The final counterpart of a "cvs update" was a simple "git pull".

# Almost too much documentation available for such simple scenarios ;_)

--
Reto S. News <retoh <at> dplanet.ch> writes:

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

end of thread, other threads:[~2009-02-22 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-21 21:23 How to update? (git Changed but not updated) Reto S. News
2009-02-22  1:10 ` Sitaram Chamarty
2009-02-22  1:32 ` Rainer Blome
2009-02-22 10:07 ` Reto Schär

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).