Your branch is ahead of ‘origin/master’ Git issue

Currently I’m working on a project called NoseyHam, this is essentially a directory site for high quality technology companies. I’m using Git for version control, showing my code and distributing my code between my Macbook at home and my work PC, while using Sublime Text 2 with the SFTP plugin to get the pages to my site.

I’m currently working on the beta sign up aspect of the site, which is essentially a form that people fill out to get priority access to the NoseyHam beta. The form is only half done but I made enough modifications to the CSS as well as some database and validation changes so I needed to commit my branch.

I first tried to commit the beta-sign-up branch with

$  git commit –am “beta signup half done”

This was getting rejected and returning

$ git commit –am “beta signup half complete” 
# On branch master 
# Your branch is ahead of ‘origin/master’ by 1 commit. 
Nothing to commit (working directory clean)

I was reading around the web and couldn’t find much on Stack Overflow (hence this blog post) but the information I found was that everyone had a different solution for this problem but I ended up fixing it by first pulling then committing adding everything back in then pushing to the origin the commands are shown below (the dots signify some data was returned but you don’t need to input).

$ git pull 
$ git commit –am “beta signup half complete” 
$ git push origin

This seemed to fix my issue and allowed me to commit my changes. I believe the issue is that the origin/master branch is behind your local copy of the files usually because you’ve added or deleted some files to your repo without pushing it, it may also have something to do with pushing a branch that has been edited somewhere else and if you were able to push you would wipe the changes that someone else has already committed.

Hopefully this helped you on your journey and if you’ve got any questions feel free to post them in the comments.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You May Also Like