将项目上载到github C#Visual Studio



我在GitHub上创建了一个名为Map的存储库。

然后转到我的GitHub项目文件夹,并成功地将其克隆到该文件夹中。它只有一个自述文件。

然后,我将Visual Studio项目下Map目录中的所有内容复制并粘贴到GitHub Map目录中。

然后我做了github push -u origin master行。

然后它说一切都是最新的,我认为这意味着没有需要添加的更改,但我确实将我的项目添加到了GitHub Map文件夹中,所以它应该有更改?

我说得对吗?

我还完成了我认为需要的所有其他命令行命令。我首先想指出为什么它可能会说"最新的",并问,我是否要将我的VS项目复制并粘贴到GitHub项目文件夹中,以添加项目?

当您使用github push -u origin master时,它可能会显示Everything up-to-date,因为听起来您实际上还没有在本地repo中进行任何提交以推送到远程。

在将源代码推送到远程存储库之前,必须先将其添加并提交到本地存储库:

git add . # Add everything in the current directory (".")
git commit
git push origin master # Now you can push.

此外,将本地repo目录与VisualStudio的工作目录分开是不寻常的。一个典型的设置是直接在您的工作目录中初始化Git repo:

cd <your-visual-studio-project-folder>
git init
git add . # Add everything in the current directory (".")
git commit
git remote add origin <url-for-your-remote>
git fetch origin
# Rebase your local root commit onto the remote root commit
git rebase --onto origin/master --root
# Now you can push to your remote
git push origin master

最后,我强烈建议您阅读免费在线Pro-Git书籍,特别是第1-3章和第6-6.5章,它将帮助您解决未来的大部分Git问题。