I created a project as a single file gist. Then I expanded my project to multiple files (by, for instance, adding README and LICENSE files). I set up two remotes on my local git repository now, which I call origin-gist and origin-github. I can push to them and everything is right with the world.
But what I actually want is for the gist to remain just the single file, without the overhead of the added stuff. How can I do that while keeping one local repository that pushes to the two remotes?
As an aside, if I could control the order that the files displayed in gist I would care less. I'm also unwilling to rename my files to induce the desired order with an ASCIIbetical sort.
Any tips?
I found information in this question useful: Transfer gist repo to github, but need some clarification.
The easiest solution is probably to keep two separate branches, one with only the script (which I would name minimal
) and one with all the extra files in it (master
). Then make sure the "upstream" for each branch is set properly:
# In the 'minimal' branch
git remote add gist git@gist.github.com:/1162032.git
git push -u gist master
# In the 'master' branch
git remote add origin git@github.com:octocat/Hello-World.git
git push -u origin master
After that, you just need to make sure that both scripts stay up to date, so any change you make to one branch should be made to the other branch as well.
You can make this easier in one of two ways:
- When you make changes,
cherry-pick
commits from one to the other. - If you
merge
themaster
branch into theminimal
branch whenever you make changes, it will add those extra files tominimal
. But assuming theminimal
branch only contains the actual script, you should be able to safely merge fromminimal
intomaster
without adding those extra files:
# First, make edits to the 'minimal' branch, commit them, then push the changes to 'gist'
# Now, apply those changes to master like this:
git checkout master
git merge --no-ff minimal -m "Update script to latest version"
git push # Push the changes to the GitHub repo
This answer doesn't directly answer the specific question you asked, but it does solve the problem at hand, and has therefore been added as an answer rather than a comment.
It is worth asking yourself, is there a reason to keep the old gist around and updated?
The easiest solution to this problem, and what I frequently see, is the gist replaced with a README document that says something like:
This gist has been moved to its own repository: http://github.com/OctoCat/HelloWorld
Take this "former gist" as a prime example: https://gist.github.com/weakish/492755
This way people who find the gist online can be directed towards the newest version of the library, and you don't have to worry about keeping both separate locations up to date.
来源:https://stackoverflow.com/questions/25675761/link-a-gist-with-a-github-repository-but-push-different-files-to-each