简体   繁体   English

将本地git repo与新的github存储库同步

[英]Sync local git repo with new github repository

I have a local git repository hosted in local sever.I would like to add the project to github repository. 我在本地服务器上托管了一个本地git存储库,我想将该项目添加到github存储库中。 I would like to keep my local repository as the main repository and github repo as backup repo. 我想将本地存储库保留为主存储库,将github存储库保留为备份存储库。

Is it possibly to keep the history(commit history) when I'm adding project to the github? 将项目添加到github时是否可以保留历史记录(提交历史记录)?

I would like to "push" every commit to local git repository, so can I sync all the local repo pushes with github repo? 我想“推送”对本地git存储库的所有提交,因此我可以将所有本地repo推送与github repo同步吗?

If above two possible, how could I achieve?, If there are link which I could refer? 如果以上两种可能,我如何实现?,如果有我可以参考的链接?

Udeshika Udeshika

Seems like you want to push existing git repository to Github 似乎您想将现有git存储库推送到Github

https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

Create a new github repo, copy its link and add the remote to your local repository. 创建一个新的github存储库,复制其链接,并将远程添加到您的本地存储库。

git remote add origin <remoteRepoUrl>

Then push your local git branch to Github. 然后将本地git分支推送到Github。 I am assuming it is master branch. 我假设它是主分支。

git push origin master

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

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