将一个要点与github存储库链接起来,但将不同的文件推送到每个文件 [英] Link a gist with a github repository, but push different files to each

查看:268
本文介绍了将一个要点与github存储库链接起来,但将不同的文件推送到每个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个项目作为单个文件的要点。然后我将项目扩展到多个文件(例如,通过添加README和LICENSE文件)。我现在在本地git存储库上设置了两个远程控制台,我称其为origin-gist和origin-github。我可以推动他们,一切都是正确的与世界。

但我真正想要的是要保持只是单个文件,没有额外的开销东东。我怎么能这样做,同时保持一个本地存储库,推到两个远程?



另外,如果我可以控制文件显示的顺序,我会少关心。

任何提示?

b
$ b p>我发现这个问题中的信息有用:将gist的回购转移到github上,但需要澄清。最简单的解决方案可能是保留两个独立的分支,一个只有脚本(我将命名为 minimal ),另一个文件中包含所有额外的文件( master )。然后确保每个分支的上游设置正确:

 #在'minimal'分支中
git远程添加gist git@gist.github.com:/1162032.git
git push -u gist master

#在'master'分支
git remote add origin git @ github.com:octocat/Hello-World.git
git push -u origin master

之后,您只需确保两个脚本都保持最新状态,所以您对一个分支所做的任何更改都应该发送给其他分支。



您可以通过以下两种方式之一来简化操作:


  1. 当您进行更改时, cherry-pick 从一个提交到另一个。

  2. 如果您 merge master 分支到最小分支中,它会将这些额外的文件添加到 minimal 中。但假设 minimal 分支只包含实际的脚本,您应该可以安全地从 minimal 合并到<$ c


    $ b

     $  

    $ > #首先,对'minimal'分支进行编辑,提交它们,然后将更改推送到'gist'
    #现在,将这些更改应用到master中,如下所示:
    git checkout master
    git merge --no-ff minimal -m将脚本更新到最新版本
    git push#将更改推送到GitHub仓库


    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:

    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
    

    这篇关于将一个要点与github存储库链接起来,但将不同的文件推送到每个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆