37

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

4

3 回答 3

30

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

cd到带有本地存储库的目录

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

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

git push -u origin master

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

于 2012-06-30T18:03:37.120 回答
4

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

2.git remote add origin <your_URL_for_github_repo.git>

(您可以origin通过输入来验证您是否拥有git remote -v。您可以看到<URL>.gitorigin

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

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

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

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

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

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

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

git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
于 2014-09-18T05:03:03.660 回答
3

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

于 2014-04-10T04:04:00.533 回答