Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对git远程行为感到惊讶_Git - Fatal编程技术网

对git远程行为感到惊讶

对git远程行为感到惊讶,git,Git,在mac OS-X Mavericks上,尝试在已装入的卷上创建源于repo的本地克隆 我创建了源代码存储库 pushd /Volumes/somevolume mkdir testbox cd testbox git init 我在其中放置、添加和提交一个文件 cat > test.text testing git remote ^D git add -A git commit -am "initial commit" 我现在将回购复制到我的普通家庭 pushd ~/Document

在mac OS-X Mavericks上,尝试在已装入的卷上创建源于repo的本地克隆

我创建了源代码存储库

pushd /Volumes/somevolume
mkdir testbox
cd testbox
git init
我在其中放置、添加和提交一个文件

cat > test.text
testing git remote
^D
git add -A
git commit -am "initial commit"
我现在将回购复制到我的普通家庭

pushd ~/Documents
git clone /Volumes/somevolume/testbox
cd testbox
cat test.text
一切都好。现在我在本地克隆中更改并提交文件

cat >> test.text
a new line
^D
git commit -am "add a new line to test.text"
检查它是否真的改变了

cat test.text
testing git remote
a new line
并将其推到远程原点

git push origin master
编辑:我收到一条我不明白的警告

Counting objects: 5, done.
Writing objects: 100% (3/3), 277 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: warning: updating the current branch
To /Volumes/lockbox/testbox/
   bb6f7d1..5d2f521  master -> master
我现在去检查文件是否被推送了

pushd /Volumes/somevolume/testbox
git status

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   test.text
#
我尝试添加和推送的新行不在这里,即使git认为该文件已被修改?在从本地工作目录推送之后,为什么我必须在originremote中执行任何操作?Github似乎不是这样工作的。也许变化就在这里的某个地方

git diff

没有可见的变化。我现在完全糊涂了。

当您将
推送到非远程存储库时,您的更改会记录到
.git
目录中的存储库中,但不会应用到存储库的签出版本(“工作副本”)。这就是为什么通常建议仅将裸存储库用作远程存储库的原因,因为否则行为可能会令人困惑

您会注意到,推送后,原始存储库显示文件
test.txt
已被修改:

pushd /Volumes/somevolume/testbox
git status

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   test.text
pushd/Volumes/somevolume/testbox
git状态
#论分行行长
#要提交的更改:
#(使用“git重置磁头…”取消分级)
#
#修改:test.text
这是因为文件现在与存储库的内容不同

“远程:警告:更新当前分支”警告提醒您正在推送到当前签出的分支


有时,您可能真的想要推送到非裸存储库(可能您正在部署一个带有
git push
或其他功能的网站),但您需要设置一个适当的机制来将更新应用到工作副本(通常需要将工作副本视为只读,以避免冲突)。

Hm,它可以让你在没有任何警告的情况下推?你用的是什么版本的git?哦,我收到了警告,但我不明白。我将编辑带有警告的问题。如何验证我的内容是否确实在裸回购中(我尝试过)?由于没有工作目录,我无法直接检查文件。Atlassian的SourceTree不会打开裸存储库。在我走这条路之前,我需要有一种方法来验证裸远程回购是否正确更新。我可以在Github上这样做,因为他们(不知怎么的)让我查看文件。我正试图在本地计算机上尽可能接近github的行为。您可以通过在某处签出来验证裸远程设备是否正确更新。明白了。完全理解。感谢:)
pushd /Volumes/somevolume/testbox
git status

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   test.text