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

Re: How to update? (git Changed but not updated)

From
RBRainer Blome <rainer.blome@gmx.de>
Date
Feb 22, 2009, 01:32 UTC
Message-ID
<49A0AB26.40701@gmx.de>
In-Reply-To
<49A070B5.90909@dplanet.ch>
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
Previous: Sitaram ChamartyNext: Reto Schär
Message 3 of 4 in “How to update? (git Changed but not updated)”
  1. Reto S. NewsFeb 21, 2009
  2. Sitaram ChamartyFeb 22, 2009
  3. Rainer BlomeFeb 22, 2009
  4. Reto SchärFeb 22, 2009

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.