0
user@host:~/dir$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
user@host:~/dir$ git checkout SMC_VFR_01_18_2019
Switched to branch 'SMC_VFR_01_18_2019'
Your branch is ahead of 'origin/SMC_VFR_01_18_2019' by 2 commits.
  (use "git push" to publish your local commits)
user@host:~/dir$

I'm concerned about that after checking out the branch there are pending commits.

  • It's all pretty run-of-the-mill. Which line(s) are you asking about? – isherwood Jan 25 '19 at 15:52
  • Possible duplicate of [Your branch is ahead of 'origin/master' by 3 commits](https://stackoverflow.com/questions/16288176/your-branch-is-ahead-of-origin-master-by-3-commits) – phd Jan 25 '19 at 16:40
  • https://stackoverflow.com/search?q=%5Bgit%5D+Your+branch+is+ahead – phd Jan 25 '19 at 16:40

3 Answers3

3

It probably means that you haven't pushed your local commits. Try running

git push
fuomag9
  • 138
  • 1
  • 12
2

The message:

Your branch is ahead of 'origin/SMC_VFR_01_18_2019' by 2 commits.

means that since you have synched your local SMC_VFR_01_18_2019 branch, you have made two commits to that branch without pushing them. Note that origin/SMC_VFR_01_18_2019 is actually a local branch as well, whose purpose is to track the true remote SMC_VFR_01_18_2019 branch. It is possible that, since you last pulled this branch, others have made commits to the remote as well.

So, you might try doing:

git fetch origin

to bring in any new commits to origin/SMC_VFR_01_18_2019 which may have happened on the remote. Then, if new commits have been made remotely, you might see a message saying that your local branch is both ahead of (your commits) and behind (others' commits) the remote branch.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • I'm unclear, why remote edits would show up as local commits. –  Jan 25 '19 at 16:08
  • @FrankPuck Remote edits in fact _would_ show up as local commits on the `origin/SMC_VFR_01_18_2019` branch, but _not_ your local branch. Read about tracking branches in Git to learn more about this. – Tim Biegeleisen Jan 25 '19 at 16:16
  • so you're saying (perfecting my confusion) this is different than working on the normal trunk where remote edits do not show up as local commits in need of push? –  Jan 25 '19 at 16:20
  • `truck` sounds a lot like SVN language to me. I would suggest that you review the official Git tutorial if you really don't follow my answer. I cannot explain things any more clearly than I already have done. – Tim Biegeleisen Jan 25 '19 at 16:20
  • All git commands and operations are done locally, except fetch, push, and pull. You haven't pushed your commits to origin. They're not _pending_, but _not shared_. It's nothing to worry about. – evolutionxbox Jan 25 '19 at 16:28
  • I worry about it, as I might have deleted this working directory (which is pretty often necessary given the combination of git&I) without being aware of losing changes. –  Jan 25 '19 at 16:32
  • Even if you did, as long as the deletion was committed you can _always_ get it back. – evolutionxbox Jan 25 '19 at 16:36
1

From official documentation

git checkout

To prepare for working on , switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the < branch>.

Note: after checkout, local modifications are kept. So in your case, local modifications are already present before the checkout that we see in the command list.

Community
  • 1
  • 1
GabrieleMartini
  • 1,665
  • 2
  • 19
  • 26
  • There were no local changes in the working directory. See the list of commands! –  Jan 25 '19 at 15:52