2016-07-06 65 views
2

我已经创建了一个linux目录的git存储库并将所有文件都推送到它。我最近将一个新文件移入了该linux目录,现在想将这个新文件推送到它的git存储库中。我试图通过在命令行中键入将新创建的文件推入git存储库

git push origin master 

这样做,但我得到的错误:

fatal: 'origin' does not appear to be a git repository 
fatal: The remote end hung up unexpectedly 

有谁知道如何把一个新的文件到该文件夹​​的现有混帐回购协议在哪个文件存在?我是git的新手,所以会很感激你的建议。

+0

您只有本地仓库还是远程仓库? –

回答

1

如果您的文件已经在您创建的git仓库中,添加和提交就足够了:无需推送。

myrepo  <== "I have created a git repository of a linux directory" 
    .git   (the .git folder is the git repo referential) 
    myNewfile <== "I have recently moved a new file into that linux directory" 

http://training-course-material.com/images/thumb/8/8d/Git-commit-a2.png/250px-Git-commit-a2.png

IE浏览器。没有远程“起源”推动本地git回购。

章节“Git Basics - Recording Changes to the Repository”是开始的好地方。

git add myNewFile 
git commit -m "Add a new file" 
+0

我明白了!所以我需要做的:git commit -m“somemessage”和git添加“文件名”来推送我添加到文件夹中的新文件? – zsha

+0

@zsha no:git add,然后git commit。更多信息,请访问https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository – VonC

+0

它现在可以工作!谢谢:) – zsha

1

看来你有一个错误的认识有关git push命令,请阅读下面的数字,这将给你一个更清洁的概念。

enter image description here

+0

感谢您的建议! – zsha

1
  1. 验证,如果你有资源库分支(在其上工作)签出。
  2. 确保您拉出第一

  3. 做“git的添加newfileNameWithPath”,你推前提交更新。

+0

感谢您的建议! – zsha

相关问题