10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gitで空ブランチを作る

Posted at

gitで空の新規ブランチを作ったときの備忘録。

やりたいこと

Testプロジェクトに空のブランチを作成する。作成する空ブランチには元になる親ブランチの歴史・ファイルを引き継がせず、新規の歴史をもたせる。

手順

まずはTestプロジェクトのクローン

$ git clone https://github.com/Test.git
$ cd Test

空ブランチkaraを作成してpush

$ git checkout --orphan kara       #親の歴史を引き継いでいないブランチを作成
$ git reset --hard                 #親のファイルを引き継いでるのでreset
$ touch README.md                  #READMEを追加
$ vim README.md
$ git add README.md
$ git commit -m "initial commit" 
$ git push origin kara        #サーバー側へpush  
10
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
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?