git 使用git在本地跟踪一个项目后,如何将其添加到GitHub?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11276364/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:10:13  来源:igfitidea点击:

After using git to locally track a project, how can I add it to GitHub?

gitgithub

提问by corazza

After using git to locally track a project, how can I add it to GitHub?

使用git在本地跟踪一个项目后,如何将其添加到GitHub?

采纳答案by Zach

GitHub gives you instructions after you've created the repository online.

在您在线创建存储库后,GitHub 会为您提供说明。

cdto the directory with the local repository

cd到本地存储库的目录

git remote add origin whatever-address-my-repository is.gitto set the remote

git remote add origin whatever-address-my-repository is.git设置遥控器

then make a commit, and push to the master branch.

然后进行提交,并推送到主分支。

git push -u origin master

git push -u origin master

https://help.github.com/articles/create-a-repo

https://help.github.com/articles/create-a-repo

回答by Asim K T

1.Create a README.mdin your local repo (for GitHub -*optional)

1.README.md在您的本地存储库中创建一个(对于 GitHub - *optional

2.git remote add origin <your_URL_for_github_repo.git>

2.git remote add origin <your_URL_for_github_repo.git>

(You can verify you have originby entering git remote -v. You could see <URL>.gitas the origin).

(您可以验证你origin的进入git remote -v。你可以看到<URL>.gitorigin)。

3.Make a commit by git commit -a -m "<a message>"

3.通过提交 git commit -a -m "<a message>"

(Important! Only committed files will be pushed to Github)

(重要!只有提交的文件才会被推送到 Github)

4.Now push to GitHub by git push -u origin master(If you pushing the master branch).

4.现在通过git push -u origin master(如果你推送主分支)推送到GitHub 。

You will be needing passwords every time you push (If you cloned using https:).For get rid of that ;

每次推送时都需要密码(如果您使用 克隆https:)。为了摆脱它;

In Terminal, enter the following:

在终端中,输入以下内容:

git config --global credential.helper cache
# Set git to use the credential memory cache

To change the default password cache timeout, enter the following:

要更改默认密码缓存超时,请输入以下内容:

git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)

回答by Laur

Here you will find the steps about how to create a repository and how to push it on Github: http://programertools.blogspot.com/2014/04/how-to-use-github.html

在这里您可以找到有关如何创建存储库以及如何将其推送到 Github 的步骤:http: //programertools.blogspot.com/2014/04/how-to-use-github.html