简体   繁体   English

从本地存储库推送到 GitHub 托管的远程

[英]Pushing from local repository to GitHub hosted remote

I created a local repository of my Visual Studio 2010 solution folder using Git GUI on my dev machine.我在我的开发机器上使用 Git GUI 创建了我的 Visual Studio 2010 解决方案文件夹的本地存储库。 I then created a remote repository in my GitHub account.然后我在我的 GitHub 帐户中创建了一个远程存储库。 Now, I am looking for how to push my local repository to the remote repository.现在,我正在寻找如何将我的本地存储库推送到远程存储库。

In SVN I can just commit using TortoiseSVN and changes are pushed to the remote repository.在 SVN 中,我可以使用 TortoiseSVN 进行提交,并将更改推送到远程存储库。 I don't see any tool like that available for Git.我没有看到任何可用于 Git 的工具。

How do I push my local repo to my remote repo on GitHub?如何将本地存储库推送到 GitHub 上的远程存储库?

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.首先使用git remote add [alias] [url]命令建立两者之间的关系后,您可以使用git push命令将本地存储库推送到远程存储库。 If you visit your Github repository, it will show you the URL to use for pushing.如果您访问您的 Github 存储库,它将向您显示用于推送的 URL。 You'll first enter something like:您将首先输入如下内容:

git remote add origin git@github.com: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.当您以后想更新远程存储库时。

Type类型

git push

from the command line inside the repository directory从存储库目录中的命令行

Subversion implicitly has the remote repository associated with it at all times. Subversion 始终隐式地拥有与之关联远程存储库。 Git, on the other hand, allows many "remotes", each of which represents a single remote place you can push to or pull from.另一方面,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.将两者关联后,您将能够推或拉分支。

This worked for my GIT version 1.8.4:这适用于我的 GIT 版本 1.8.4:

  1. From the local repository folder, right click and select ' Git Commit Tool '.从本地存储库文件夹中,右键单击并选择“ Git Commit Tool ”。
  2. 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.) (您最初可以单击“重新扫描”按钮来检查哪些文件已修改但尚未上传。)
  3. Write a Commit Message and click ' Commit ' button.编写提交消息并单击“提交”按钮。
  4. Now right click in the folder again and select ' Git Bash '.现在再次右键单击该文件夹并选择“ Git Bash ”。
  5. Type: git push origin master and enter your credentials.输入: git push origin master并输入您的凭据。 Done.完毕。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM