-1

What I want to do

I just would like to solve this message

This branch is 2 commits ahead, 13 commits behind master.

Why it happened

I did git pull on my develop branch by mistake. Apparently, I did git commit -m a couple of times after I did that. That's why I'm getting this message.

Detail

I found several solutions about my problem but I cannot tell from which is a right solution to me. I am not familiar with git so I cannot understand what doing git pull on a develop branch caused to my repository.

If it is alright with you, I would like you to tell me how to solve this problem and what is going on my repository.

Thank you very much.

This is the result of my git reflog

25a9c24 (HEAD -> develop, origin/develop) HEAD@{0}: commit: [Add] 進行中の取引一覧ページ追加 #150
1c15093 HEAD@{1}: checkout: moving from master to develop
ad6582f (origin/master, master) HEAD@{2}: pull: Fast-forward
0b4d412 HEAD@{3}: checkout: moving from develop to master
1c15093 HEAD@{4}: commit: [Fix] Request_Deal_TableをDealにも対応できるよう更新
2a0e143 HEAD@{5}: commit: [Update]申請されたリクエスト一覧ページ完成 #149
aabb0e8 HEAD@{6}: commit: [Update] Request_Waitingに画面遷移機能追加
2f82622 HEAD@{7}: checkout: moving from master to develop
0b4d412 HEAD@{8}: pull: Fast-forward
aa9e763 HEAD@{9}: checkout: moving from develop to master
2f82622 HEAD@{10}: commit: [Update] Request_Detail完成 #143
baa5d3f HEAD@{11}: checkout: moving from master to develop
aa9e763 HEAD@{12}: pull: Fast-forward

mike
  • 1,233
  • 1
  • 15
  • 36
Toshi023Yuki
  • 315
  • 3
  • 12

1 Answers1

0

In git, you normally have one local and one remote version of each branch stored in your machine. In your case, your remote is named origin and you have the branches master and origin/master, develop and origin/develop. The remote version of your branches is bound to a url where that branch can synchronize its states. You can see your remote informations using the command: git remote -v

When you do git checkout develop and than git pull, git does the following:

  • brings all the new commits from develop branch on remote url to the origin/develop branch in your machine
  • merges the origin/develop branch to develop branch

The message bellow means your current branch has two commits that are not present in master branch and master branch has 13 commits your current branch doesn't have.

This branch is 2 commits ahead, 13 commits behind master.

If you want to make your develop branch have all master branch commits you merge master into your develop by running git merge master.

To better understand the git branches I recommend to use visual tools like gitk.

The command gitk --all will display the state of all your branches:

enter image description here

  • Thank you for your great explanation. I understand what situation I am in now. However, I still don't find how I can solve this issue. – Toshi023Yuki Oct 08 '20 at 19:06
  • I updated the answer adding the following. Check if it is what you need: "If you want to make your `develop` branch have all `master` branch commits you merge master into your develop by running `git merge master`." – Sidnei Bernardo Oct 09 '20 at 11:36
  • Thank you. Actually, I figured it out in another way but this is a new good way. It's good study to me. Thank you very much again. – Toshi023Yuki Oct 10 '20 at 18:22