将本地文件推送到github repo

时间:2015-12-22 07:24:31

标签: git github

我的本​​地仓库中有一个文件,我想将其推送到我的Github仓库中的目录。

我有以下文件:

F:\Development\Python\Workspace\StringCalculator.py

我需要将此文件推送到我的仓库的以下路径:

https://github.com/Gouravchawla/PyCodeFiesta/tree/master/GUI

如何将文件推送到此位置?我在Git Shell中尝试了以下命令:

$ git remote add newremote https://github.com/Gouravchawla/PyCodeFiesta/tree/master/GUI
$ git push newremote master

当我执行上述命令时,出现以下错误:

fatal: repository 'https://github.com/Gouravchawla/PyCodeFiesta/tree/master/GUI/' not found

我真的很感激这方面的任何帮助和见解。

1 个答案:

答案 0 :(得分:3)

您无法将单个文件推送到远程存储库中的目录。 Git使用完整目录快照,您只能推送提交(历史记录)。

因此,要将文件存入存储库,必须创建包含文件的提交:

git clone https://github.com/Gouravchawla/PyCodeFiesta
cd PyCodeFiesta
cp 'F:\Development\Python\Workspace\StringCalculator.py' GUI/
git add GUI/StringCalculator.py
git commit -m 'Added StringCalculator file'
git push origin master:master
相关问题