LoginSignup
5
7

More than 5 years have passed since last update.

publicで公開してしまったgistをsecretにする方法

Last updated at Posted at 2016-09-12

はじめに

現在、gistをpublicからsecretに変更する方法は提出されていません。
今回は、publicで作成してしまったgistを新規に作成するsecretのリポジトリに移し変えることで代用しようと思います

1 publicで上げたgistをローカルに落とす

まず、publicで上げてしまったgistのCopy to clipboardをClone via HTTPSにし、urlをコピーし、コマンドラインで 
 $ git clone "publicの方のurl"
$ cd "cloneしたフォルダ" 

します

2 privateでgistを作成

誤って上げてしまったファイルと同じ名前でNew gistをCreate secret gistで作成し、gistのCopy to clipboardをClone via HTTPSにし、urlをコピーします。

3 git push -fで強制的に書き換える

コマンドラインで
$ git remote set-url origin "privateの方のURL"
し、remote urlを切り替えます。最後に
$ git push -f origin master
で強制的にpushしてあげれば完了です。これでログも残ったままpublic gistをprivate gistに切り替えれます。

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7