为什么“git status”不能让我在共享仓库中更改文件?

时间:2016-10-12 22:19:02

标签: git git-status

以前曾经问过这个问题,但我仍然在苦苦挣扎。

这是我的流程:

# 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(+)

为什么“git status”没有看到2ND CLONE添加的README文件,但是“git pull”呢?

我看到了这样的信息:

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

但是,对我来说......主人已经更新,并且“git status”应该提到README文件。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

Git不会自动更新克隆。因此,即使第二个克隆发生了变化,并且遥控器知道它们,第一个克隆也不知道readme存在直到拉动。

Git是显式的,因此无需从远程提取或取出,本地存储库中不会发生任何变化。