git 将项目上传到 github C# Visual Studio
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18312911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upload a project to github C# Visual Studio
提问by user2602079
I created a repository on GitHub called Map.
我在 GitHub 上创建了一个名为 Map 的存储库。
Then went to my GitHub projects folder and successfully cloned it to that folder. It only had a readme file.
然后转到我的 GitHub 项目文件夹并成功将其克隆到该文件夹。它只有一个自述文件。
Then I copied and pasted everything in my Map directory under Visual Studio projects into my GitHub Map directory.
然后我将 Visual Studio 项目下 Map 目录中的所有内容复制并粘贴到我的 GitHub Map 目录中。
Then I did the github push -u origin master
line.
然后我做了github push -u origin master
线。
Then it said everything up-to-date which i think means there was no changes to add, but I did add my project to the GitHub Map folder so it should have had changes?
然后它说所有内容都是最新的,我认为这意味着没有要添加的更改,但是我确实将我的项目添加到了 GitHub Map 文件夹,所以它应该有更改?
Am I going about this correctly?
我这样做正确吗?
I also did all the other command line commands required I believe. I first want to point out why it might say "up-to-date" and ask, do I copy and paste my VS project into the GitHub project folder, to add the project?
我还执行了我认为所需的所有其他命令行命令。我首先想指出为什么它可能会说“最新”并问,我是否将我的 VS 项目复制并粘贴到 GitHub 项目文件夹中,以添加项目?
采纳答案by user2602079
It probably says Everything up-to-date
when you github push -u origin master
because it sounds like you haven't actually made any commits in your local repo to push to your remote yet.
它可能会说Everything up-to-date
当你github push -u origin master
因为听起来你实际上还没有在本地存储库中进行任何提交来推送到你的远程。
Before you push source code to a remote repo, you must first add and commit it to your local repository:
在将源代码推送到远程存储库之前,您必须首先将其添加并提交到本地存储库:
git add . # Add everything in the current directory (".")
git commit
git push origin master # Now you can push.
Also, it's unusual that you would keep your local repo directory separate from your working directory for Visual Studio. A typical setup would be to just initialize a Git repo directly in your working directory:
此外,您将本地 repo 目录与 Visual Studio 的工作目录分开是不寻常的。一个典型的设置是直接在你的工作目录中初始化一个 Git 仓库:
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
Finally, I highly recommendthat you read the FREEonline Pro Git book, especially chapters 1-3 and 6-6.5, it will help you with most of your future Git problems.
最后,我强烈建议您阅读免费的在线 Pro Git 书籍,尤其是第 1-3 章和第 6-6.5 章,它将帮助您解决大多数未来的 Git 问题。