2016-07-06 78 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

相關問題