0

This has been asked before, but I'm still struggling with it.

Here's my flow:

# INIT REPOSITORY
/path/git % mkdir test.git
/path/git % cd test.git
/path/git/test.git % git init --bare --shared
Initialized empty shared Git repository in /path/git/test.git/

# 1ST CLONE
/path/test1 % ls
/path/test1 % git clone /path/git/test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
done.

# 2ND CLONE
/path/test2 % git clone /path/git/test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
done.

# ADD README TO 2ND CLONE
/path/test2/test % vim README
/path/test2/test % git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        README

nothing added to commit but untracked files present (use "git add" to track)
/path/test2/test % git add .
/path/test2/test % git commit . -m "add README"
[master (root-commit) 22757c9] add README
 1 file changed, 1 insertion(+)
 create mode 100644 README
/path/test2/test % git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 218 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /path/git/test.git
 * [new branch]      master -> master

# *** BACK TO 1ST CLONE - GIT STATUS ISSUE! ***
/path/test1 % git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean**

/path/test1 % git pull
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /path/git/test
   852bd11..8512257  master     -> origin/master
Updating 852bd11..8512257
Fast-forward
 README | 1 +
 1 file changed, 1 insertion(+)

Why doesn't "git status" see the README file addition by 2ND CLONE, but "git pull" does?

I'm seeing the message:

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean**

But, to me ... the master has been updated and that README file should have been mentioned by "git status".

Any ideas?

  • Where does `git status` not show the `README` addition? Where do you issue the command for your last output block, and what is it? – Tom Hale Oct 13 '16 at 02:38
  • Hi Tom, you need to scroll down in my example above. You can see it near the end. After adding a README first to the 2nd CLONE, I'm simply using "git status" and then "git pull" afterward in the 1st CLONE. And "git status" isn't telling me that the master has been updated. – Antonio Dimalanta Oct 13 '16 at 03:54
  • Thanks all ... I think I misunderstood the functionality of "git status" which seems to only track files/directories in the work area and staging directory (add, commit) and not files/directories changed in the master repo. – Antonio Dimalanta Oct 13 '16 at 04:40
  • Possible duplicate of [Confused by 'up-to-date' message in git workflow](http://stackoverflow.com/questions/39869483/confused-by-up-to-date-message-in-git-workflow) – 1615903 Oct 13 '16 at 04:58

1 Answers1

1

Git doesn't automatically update clones. So, even though the changes happened in the 2nd clone and the remote knew about them, the 1st clone had no idea the readme existed until the pull.

Git is explicit, so without pulling or fetching from the remote, nothing will change within the local repository.

Briana Swift
  • 1,047
  • 8
  • 9