Link a gist with a github repository, but push different files to each

白昼怎懂夜的黑 提交于 2019-12-04 16:36:50

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:

  1. When you make changes, cherry-pick commits from one to the other.
  2. If you merge the master branch into the minimal branch whenever you make changes, it will add those extra files to minimal. But assuming the minimal branch only contains the actual script, you should be able to safely merge from minimal into master 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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!