git 从本地存储库推送到 GitHub 托管的远程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10573957/
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
Pushing from local repository to GitHub hosted remote
提问by quakkels
I created a local repository of my Visual Studio 2010 solution folder using Git GUI on my dev machine. I then created a remote repository in my GitHub account. Now, I am looking for how to push my local repository to the remote repository.
我在我的开发机器上使用 Git GUI 创建了我的 Visual Studio 2010 解决方案文件夹的本地存储库。然后我在我的 GitHub 帐户中创建了一个远程存储库。现在,我正在寻找如何将我的本地存储库推送到远程存储库。
In SVN I can just commit using TortoiseSVN and changes are pushed to the remote repository. I don't see any tool like that available for Git.
在 SVN 中,我可以使用 TortoiseSVN 进行提交,并将更改推送到远程存储库。我没有看到任何可用于 Git 的工具。
How do I push my local repo to my remote repo on GitHub?
如何将本地存储库推送到 GitHub 上的远程存储库?
回答by larsks
You push your local repository to the remote repository using the git push
command after first establishing a relationship between the two with the git remote add [alias] [url]
command. If you visit your Github repository, it will show you the URL to use for pushing. You'll first enter something like:
git push
首先使用命令建立两者之间的关系后,您可以使用命令将本地存储库推送到远程存储库git remote add [alias] [url]
。如果您访问您的 Github 存储库,它将向您显示用于推送的 URL。您将首先输入以下内容:
git remote add origin [email protected]:username/reponame.git
Unless you started by running git clone
against the remote repository, in which case this step has been done for you already.
除非您首先git clone
针对远程存储库运行,否则此步骤已经为您完成。
And after that, you'll type:
之后,您将键入:
git push origin master
After your first push, you can simply type:
第一次推送后,您只需键入:
git push
when you want to update the remote repository in the future.
当您以后想更新远程存储库时。
回答by Gareth
Type
类型
git push
from the command line inside the repository directory
从存储库目录中的命令行
回答by Daniel Pittman
Subversion implicitly has theremote repository associated with it at all times. Git, on the other hand, allows many "remotes", each of which represents a single remote place you can push to or pull from.
Subversion始终隐式地拥有与之关联的远程存储库。另一方面,Git 允许许多“远程”,每个“远程”代表一个您可以推入或拉出的远程位置。
You need to add a remote for the GitHub repository to your local repository, then use git push ${remote}
or git pull ${remote}
to push and pull respectively - or the GUI equivalents.
您需要将 GitHub 存储库的远程添加到本地存储库,然后使用git push ${remote}
或git pull ${remote}
分别推送和拉取 - 或 GUI 等效项。
Pro Git discusses remotes here: http://git-scm.com/book/ch2-5.html
Pro Git 在这里讨论遥控器:http: //git-scm.com/book/ch2-5.html
The GitHub help also discusses them in a more "task-focused" way here: http://help.github.com/remotes/
GitHub 帮助也在此处以更“以任务为中心”的方式讨论它们:http: //help.github.com/remotes/
Once you have associated the two you will be able to push or pull branches.
将两者关联后,您将能够推或拉分支。
回答by shasi kanth
This worked for my GIT version 1.8.4:
这适用于我的 GIT 版本 1.8.4:
- From the local repository folder, right click and select 'Git Commit Tool'.
- There, select the files you want to upload, under 'Unstaged Changes' and click 'Stage Changed' button. (You can initially click on 'Rescan' button to check what files are modified and not uploaded yet.)
- Write a Commit Message and click 'Commit' button.
- Now right click in the folder again and select 'Git Bash'.
- Type: git push origin masterand enter your credentials. Done.
- 从本地存储库文件夹中,右键单击并选择“ Git Commit Tool”。
- 在那里,在“未暂存更改”下选择要上传的文件,然后单击“暂存更改”按钮。(您最初可以单击“重新扫描”按钮来检查哪些文件已修改但尚未上传。)
- 编写提交消息并单击“提交”按钮。
- 现在再次右键单击该文件夹并选择“ Git Bash”。
- 输入:git push origin master并输入您的凭据。完毕。
回答by pushpendra yadav
open the command prompt Go to project directory
打开命令提示符转到项目目录
type git remote add origin your git hub repository location with.git
输入 git remote add origin 你的 git hub 存储库位置 with.git