Commits not being pushed to origin

I changed some files locally, added them, and committed them. When I try to push this branch to origin so that I can open a merge request, it seems that it isn’t pushing any changes since the Total is 0

~/work/pr $ git commit -m "something"
[master e9bd370] something
 5 files changed, 86 insertions(+), 11 deletions(-)
 create mode 100644 arrows.png
 create mode 100644 foo.html
~/work/pr $ git push origin newbranch
Total 0 (delta 0), reused 0 (delta 0)
To git@hosted.gitlab.repo:user/my-repo.git
 * [new branch]      newbranch -> newbranch

The above lets me open a new merge request on GitLab webpage, however, says “nothing to merge”. Which is because the Total 0 in the above terminal output.

  • Gitlab and Apache can't handle ~20mb push
  • Gitlab prompts for password while push for git user
  • What Happens When Import Git Repos to GitLab
  • How to migrate from Git-Annex to Git LFS
  • gitolite disallow access for directory on master branch but not on user branch
  • retrieving post data from web hook in jenkins
  • Failed Test in Gitlab
  • Automatically access submodule via ssh or https
  • 2 Solutions collect form web for “Commits not being pushed to origin”

    That looks totally normal. Your “newbranch” clearly has nothing new to add to the conversation.

    I assume you were here:

    git checkout master        # whatever the current branch is, assuming master
    

    You probably meant to do, starting from above:

    git commit -m "Something"
    git branch -f newbranch    # re-position the new branch
    git push origin newbranch
    

    That’s not the best practice, though. You should have done:

    git checkout newbranch
    # get the "newbranch" updated with the latest available "good stuff"
    git merge master
    # work on something and commit
    git commit -m "Something"
    git status
    # "git graph" here would be very useful to look at (see extra hint, below)
    git push origin newbranch
    

    PS. Extra tip – Use a handy alias git graph to visualize your branches while working, basically a super-powered git log / git status (more like log, less like status). https://sites.google.com/site/sudokillall9/articles/gitgraphvariants

    According to your commit result, it looks like you were on master when you made the commit.

    Since you are committing it to master, instead of newbranch, nothing in newbranch was changed.

    You need to checkout the newbranch branch before committing / pushing if you want to update that one.

    Git Baby is a git and github fan, let's start git clone.