Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
775 views
in Technique[技术] by (71.8m points)

git - Transfer gist repo to github

I am working on a small project with gist and since it is growing I would like to put it on github.

Let's suppose that:

The ideal solution would be one that pushes my changes on both the gist and the github repository.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can add the github repository as a remote to your checked out gist repository.

git clone git@gist.github.com:1234.git
git remote add github git@github.com:ChrisJamesC/myNewProject.git

Push it to initialize the git on github

git push -u github master

If your github repo wasn't quite empty (you created it with a README, license, etc. which you don't mind losing) you will have to do a force overwrite on your push

git push -f -u github master

If you don't want to lose the exiting commits and files, see https://stackoverflow.com/a/40408059/117471

This will also change the upstream of the branch, so github will be default.

You now can rename the remote of gist:

git remote rename origin gist

Each time you make changes (or pull changes from github/gist), you can do:

git push                 # To github
git push gist master     # To gist

This will also push back your changes to the gist and not only the github repo.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...