我正在尝试创建一个远程git代码库(我使用--bare选项对其进行了初始化),并将一些源文件推送到其中。
我有一个本地的git仓库和一个空的遥控器:
ubuntu@ip-LOCAL-IP:~/notebooks$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
[remote "nbcsm"]
url = ssh://ubuntu@ec2-RE-DA-CT-ED.compute1.amazonaws.com/home/ubuntu/notebooks/.git
fetch = +refs/heads/*:refs/remotes/nbcsm/*我用以下命令创建了本地存储库: 1. git init 2. git add *.ipynb 3. ` `git -m "first import of IPython Notebook“
然后,通过使用vi编辑*.ipynb文件,然后运行git status,我验证了我的本地存储库是否跟踪了其中的文件。git确实看到了更改后的文件。
然而,当我执行git push nbcsm master时,推送似乎是成功的,但我的远程计算机/实例上的目标目录是空的(即,它不包含我试图推送到远程的文件):
ubuntu@ip-LOCAL-IP:~/notebooks$ git push nbcsm master
Enter passphrase for key '/home/ubuntu/.ssh/id_rsa':
Counting objects: 11, done.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 2.49 KiB, done.
Total 9 (delta 5), reused 0 (delta 0)
To ssh://ubuntu@ec2-ec2-RE-DA-CT-ED.amazonaws.com/home/ubuntu/notebooks/.git
7a50f44..295a4fa master -> master
ubuntu@ip-LOCAL-IP:~/notebooks$验证文件是否不在远程:
ubuntu@ip-LOCAL-IP:~/notebooks$ ssh ubuntu@ec2-ec2-RE-DA-CT-ED.compute-1.amazonaws.com
Enter passphrase for key '/home/ubuntu/.ssh/id_rsa':
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-25-virtual x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Tue Dec 18 16:46:23 UTC 2012
System load: 0.02 Processes: 63
Usage of /: 41.7% of 7.97GB Users logged in: 0
Memory usage: 12% IP address for eth0:REMOTE-IP
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest
http://www.ubuntu.com/business/services/cloud
*** /dev/xvda1 will be checked for errors at next reboot ***
ubuntu@REMOTE-IP:~$ sudo find /home/ubuntu/ -name "*.ipynb"
/home/ubuntu/notebooks/Untitled0.ipynb
ubuntu@ip-REMOTE-IP:~$ 本地存储库中大约有12个*.ipynb文件未被推送。我相当确定这是一个概念问题,而不是语法问题,但我一遍又一遍地阅读O‘’Reilly书中的Remote一章,我被难住了。
发布于 2012-12-19 02:12:06
git push不会更新远程端的工作目录,除非您通过其中一个钩子脚本显式地告诉它。通常,如果您在远程端检查的分支是您正在推送的分支之一,它会大声抱怨并拒绝推送。但是,可以禁用该警告,允许您推送,但它仍然不会更新工作目录。您可以在远程存储库(或git checkout master或类似的东西)中运行git reset --hard HEAD,也可以设置一个post-receive钩子来为您完成这项工作。不过,让远程存储库是空的可能更好-可能会引入第三个存储库,以便您的开发存储库可以推送到那里,而您的生产存储库可以从中提取。
编辑:好的,现在这是一个不同的问题,因为您提到您的远程存储库是用--bare创建的。如果您的远程存储库是空的,那么您不应该期望以“正常”的方式在那里看到您的文件,因为一个空的存储库没有与之关联的工作目录。相反,您将看到一些子目录(如branches、hooks、info、objects和refs)和文件(config、description、HEAD),它们通常位于非裸存储库中的.git下。不过,您仍然可以运行git log和其他命令(如git show HEAD:<some_file>)来验证您的数据是否在那里。
发布于 2012-12-19 01:08:45
git status说git会看到文件发生了变化。
git status应该会告诉您没有文件正在被修改!
git status
# On branch master
nothing to commit (working directory clean)如果它列出了修改过的文件,您需要先添加并提交这些文件,然后再推送:
git add .
git commit -m "my commit message"
git push -u nbcsm master 另外,确保并检查在服务器端检出了哪个分支:
cd /home/ubuntu/notebooks
git branch在没有警告的情况下,您不应该能够推送到非裸回购。
但是由于您没有这样的分支,所以有可能另一个分支被签出了。
https://stackoverflow.com/questions/13937816
复制相似问题