在Github中将本地存储库推送到远程 [英] Push local repository to remote in Github
问题描述
我有一个包含一个名为Calculator的java文件的java项目。我在Github中创建了一个存储库,我尝试通过以下方式将本地存储库推送到远程存储库:首先:我创建了自述文件 echo #简单Java计算器>> README.md
第二: git init
第三: git add README.md
第四: git commit -m简单的计算器
第五: git remote add origin https://github.com/ XXXXX / Calc.git
第六: git push -u origin master
之后,我在网上检查了资料库,并且只找到了读我文件。我后来想到我们需要添加Calculator文件,并尝试了以下选项:
git add。
git push -u origin master
和this选项
git add Calculator.java
git push -u origin master
但两者都不起作用,并且该文件尚未存在于远程存储库中。有人可以帮我解决这个问题。
Git使用add将文件添加到索引。然后提交提交索引中的文件,然后推送与另一个存储库共享您的提交。
由于您尚未提交,因此您需要键入
git commit
完成
后
git add
在您做之前
git push
-u you用于push命令,告诉git master始终应该推送到原点,所以你只需要第一次使用它。从现在开始,您应该可以输入:
git push
而不是
git push -u原点大师
I have a java project that contains one java file called Calculator. I created a repository in Github and I tried to push the local repository to the remote one by following:
First: I created a readme file echo "# Simple Java calculator" >> README.md
Second: git init
Third: git add README.md
Fourth: git commit -m "simple calculator"
Fifth: git remote add origin https://github.com/XXXXX/Calc.git
Sixth: git push -u origin master
After that I checked the repository online and I only found the Read me file. I later figured our I need to add the Calculator file and I tried the following options:
git add .
git push -u origin master
and this option
git add Calculator.java
git push -u origin master
but both did not work and the file is not in the remote repository yet. Can someone help me with this
Git uses add to add files to the index. Then commit to commit the files in the index and then push to share your commits with another repository.
Since you've not made a commit, you need to type
git commit
after you've done a
git add
and before you do a
git push
The -u you use to the push command, tells git that master should always push to master on origin, so you just need to use that the first time. From now on it should be enough for you to type:
git push
instead of
git push -u origin master
这篇关于在Github中将本地存储库推送到远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!