Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Your branch is ahead of 'origin/master' by 3 commits

Tags:

git

git-rebase

I am getting the following when running git status

Your branch is ahead of 'origin/master' by 3 commits. 

I have read on some other post the way to fix this is run git pull --rebase but what exactly is rebase, will I lose data or is this simple way to sync with master?

like image 368
FluxEngine Avatar asked Apr 29 '13 21:04

FluxEngine


People also ask

How do I fix my branch is ahead of origin master by three commits?

This message from git means that you have made three commits in your local repo, and have not published them to the master repository. The command to run for that is git push {local branch name} {remote branch name} .

What does your branch is ahead of origin master by 1 commit mean?

The message you're seeing (your branch is ahead by 1 commit) means that your local repository has one commit that hasn't been pushed yet. In other words: add and commit are local operations, push , pull and fetch are operations that interact with a remote.

How can a branch be ahead and behind Master?

A branch can be both ahead and behind at the same time if you have made changes to your branch, and someone else have made changes on the default branch that you have not merged into your branch yet.


1 Answers

You get that message because you made changes in your local master and you didn't push them to remote. You have several ways to "solve" it and it normally depends on how your workflow looks like:

  • In a good workflow your remote copy of master should be the good one while your local copy of master is just a copy of the one in remote. Using this workflow you'll never get this message again.
  • If you work in another way and your local changes should be pushed then just git push origin assuming origin is your remote
  • If your local changes are bad then just remove them or reset your local master to the state on remote git reset --hard origin/master
like image 171
iberbeu Avatar answered Sep 28 '22 03:09

iberbeu