如下面的命令所示,git clone已成功用作git存储库并且已将更改推送到它。但是,git status没有检测到更新的克隆和原始git存储库之间的任何差异 - 为什么?
$ mkdir -p /var/tmp/git_master
$ cd /var/tmp/git_master
$ git clone https://the_repo.com/stuff.git
Cloning into 'stuff'...
~
~
~
$ cd
$ mkdir fooey
$ cd fooey
$ git clone /var/tmp/git_master/stuff
Cloning into 'stuff'...
done.
$ cd stuff/
$ git branch test
$ git checkout test
Switched to branch 'test'
$ touch test.txt
~
~
~
$ git commit -m"initial"
$ git push origin test
Counting objects: 6, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 526 bytes | 0 bytes/s, done.
Total 6 (delta 2), reused 0 (delta 0)
To /var/tmp/git_master/stuff
* [new branch] test -> test
$ pushd /var/tmp/git_master/stuff
$ git branch
* master
test
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
$
为什么git status
报告/var/tmp/git_master/stuff
不包含名为test
且不在远程存储库https://the_repo.com/stuff.git
中的本地分支?
接受回答的输出git branch -avv
$ git branch -avv
* master 52a921c [origin/master] some message
test 39dbcbf some message
remotes/origin/HEAD -> origin/master
remotes/origin/xyz b5edac5 some message
remotes/origin/master 52a921c some message
引出另一个问题:如何将/var/tmp/git_master/stuff
中的所有更改推送到远程存储库https://the_repo.com/stuff.git
? (我相信这个后续问题不需要单独提出,因为它完成了原始问题所解决的问题。)
可以在https://stackoverflow.com/a/6232535/1823664 - git checkout test
后跟git push -u
找到后续问题的解决方案。还有一些人嘲笑过这样的建议:https://stackoverflow.com/a/21232996/1823664
答案 0 :(得分:2)
为什么
git status
报告/var/tmp/git_master/stuff
不包含名为test
且不在远程存储库https://the_repo.com/stuff.git
中的本地分支?
要确切地看到这一点,请输入:
git branch -avv
您会看到test
未与任何远程跟踪分支相关联
与master
相对,与origin/master
相关联。