git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rainer Blome <rainer.blome@gmx.de>
To: "Reto S. News" <retoh@dplanet.ch>
Cc: git@vger.kernel.org
Subject: Re: How to update? (git Changed but not updated)
Date: Sun, 22 Feb 2009 02:32:22 +0100	[thread overview]
Message-ID: <49A0AB26.40701@gmx.de> (raw)
In-Reply-To: <49A070B5.90909@dplanet.ch>

[-- 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 --]

  parent reply	other threads:[~2009-02-22  1:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2009-02-22 10:07 ` Reto Schär

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49A0AB26.40701@gmx.de \
    --to=rainer.blome@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=retoh@dplanet.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).