1
1

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 で複数 branch による開発

Posted at

add-a, add-b ブランチを作成

$ git branch
* master
$ git branch add-a
$ git branch add-b
$ git branch
  add-a
  add-b
* master

master -> add-a ブランチへ切り替える

$ git checkout add-a
Switched to branch 'add-a'

add-a ブランチで a.txt を追加

a.txt
a

差分(a.txt)をリモートリポジトリへ push

$ git add .
$ git commit -m "add a.txt"
$ git push --set-upstream origin add-a

add-a -> add-b ブランチへ切り替える

$ git branch
* add-a
  add-b
  master
$ git checkout master-b
Switched to branch 'add-b'

add-b ブランチで b.txt を追加

b.txt
b

GitHub で base:master <- compare:add-a の pull request を作成、マージ

master ブランチの差分を add-b ブランチに反映

$ git pull origin master

差分(b.txt)をリモートリポジトリへ push

$ git add .
$ git commit -m "add b.txt"
$ git push --set-upstream origin add-b

GitHub で base:master <- compare:add-b の pull request を作成、マージ

リモートの master ブランチに a.txt, b.txt が追加されているため、ローカルに反映

$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
$ git pull
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?