[Fixed]-Git- local master branch appears to be broken

1👍

For your questions:

  1. Yes, you can replace master branch with pipelineProject branch. First you should make pipelineProject branch to track origin/master, use git checkout pipelineProject and git branch pipelineProject -u origin/master, then delete local master branch git branch –D master, finally rename pipelineProject to master git branch -m pipelineProject master
  2. Yes, there has a reason for it. It’s caused by the local master branch is ahead of origin/master branch for remote (you can use git status to check), and you can view commits which are ahead of the origin/master, use git log origin/master..master. So for your situation you need to drop the “broken” commit, you can use git reset --hard <commit id which you want go back>(if you do’t willing to delete master branch)

0👍

  1. Make sure your local & remote master are in same commit-sha
    $ git checkout pipelineProject # go to your pipelineProject branch
    $ git branch -D master # delete the local master branch

    Then go to online and copy the master’s last commit sha
    $ git checkout paste-commit-sha-here # go to the remote master's last commit
    $ git checkout -b master # create & checkout local master branch

  2. Replace local master with pipelineProject and push to server

    $ git checkout pipelineProject # go to your pipelineProject branch
    $ git branch -D master # delete the local master branch
    $ git checkout -b master # create & checkout new local master
    $ git push -f origin master # push to server forcely

Leave a comment