LoginSignup
5
1

More than 3 years have passed since last update.

Gitのマージ操作

Last updated at Posted at 2019-07-17

開発では最終的にmasterブランチにマージする。

現在のブランチは以下の通り

terminal
/Users/sf213471118/git/test
$ git branch
* master
  practice

現在、それぞれのブランチには以下のものが格納されている

Branch File1 File2
master README.md -
practice README.md div.md

これを以下のようにしたい

Branch File1 File2
master README.md div.md

マージする際には

$ git merge <Subject file>

とするだけでマージされる。あとはaddしてcommitすれば完了。

実際にやってみる。

terminal
/Users/sf213471118/git/test
$ git checkout master          /* masterブランチに移動 */
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ git branch   /* 移動確認 */
* master
  practice
$ git merge practice           /* masterにマージ */
Updating 0226a43..c44954c
Fast-forward
 div.md | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 div.md
$ ls                           /* masterブランチの中を確認 */
README.md   div.md

あとはaddしてcommitしてpushして終わり

terminal
/Users/sf213471118/git/test
$ git add -A                              /* add */
$ git commit -m "merge from practice"     /* commit */
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
$ git push origin master                  /* push */
Total 0 (delta 0), reused 0 (delta 0)
remote: detect-secrets-stream (beta) ver=252-281d7c3a32923b0277f57f164c55764676echrud FAQ: xxxx
remote: 
remote: Successfully send push metadata.
remote: Push info collect pre-receive hook finished within 3 seconds.
To xxxx:sf213471118/test.git
   0326b84..c43955a  master -> master

GitHub上で確認して完了

5
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
5
1