Skip to content

Instantly share code, notes, and snippets.

@billbonney
Last active November 9, 2021 23:24
Show Gist options
  • Select an option

  • Save billbonney/76de0f1a2e79f3a8a1a5 to your computer and use it in GitHub Desktop.

Select an option

Save billbonney/76de0f1a2e79f3a8a1a5 to your computer and use it in GitHub Desktop.

Revisions

  1. billbonney revised this gist Apr 14, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix_master_branch.md
    Original file line number Diff line number Diff line change
    @@ -27,5 +27,5 @@ Also useful comamnds are
    ```
    make clean # Do this in the root build dir
    git git clean -d -f -x # get rid of all not git files (be warned you could lose work if you haven't committed those changes
    git clean -d -f -x # get rid of all not git files (be warned you could lose work if you haven't committed those changes
    ```
  2. billbonney revised this gist Apr 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix_master_branch.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ git checkout upstream/master
    git branch -D master
    git branch master
    git checkout master
    git push --force origin master
    git push --force origin master #This step is only required if you pushed your 'mess' to origin ;)
    ```

    Also useful comamnds are
  3. billbonney revised this gist Apr 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix_master_branch.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ git checkout master
    git fetch upstream master
    git reset --hard <commit_where_it_diverges>
    git merge --ff-only upstream/master # if this fails you have found the point far back enough in time before the divergence
    git push --force origin master
    git push --force origin master #This step is only required if you pushed your 'mess' to origin ;)
    #(Option 2) Fix by deleting master and starting again with a fresh copy
    #Warning this will delete any changes you have made on master
  4. billbonney revised this gist Oct 4, 2014. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions fix_master_branch.md
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,11 @@ git branch -D master
    git branch master
    git checkout master
    git push --force origin master
    ```

    Also useful comamnds are
    ```
    make clean # Do this in the root build dir
    git git clean -d -f -x # get rid of all not git files (be warned you could lose work if you haven't committed those changes
    ```
  5. billbonney renamed this gist Sep 24, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. billbonney renamed this gist Sep 24, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. billbonney renamed this gist Sep 24, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. billbonney created this gist Sep 24, 2014.
    24 changes: 24 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    If your master branch of your fork has diverged from upstream master you can check your master by typing
    ```
    git checkout master
    git fetch upstream master
    git merge --ff-only upstream/master # if this fails your master is not the same as upstream i.e. it won't fast-forward
    ```
    To clean up your master try (Option 2 is simpler, Option 1 downloads less)
    ```
    # (Option 1) Fix master from point of divergence
    #WARNING: you will lose your changes to master
    git checkout master
    git fetch upstream master
    git reset --hard <commit_where_it_diverges>
    git merge --ff-only upstream/master # if this fails you have found the point far back enough in time before the divergence
    git push --force origin master
    #(Option 2) Fix by deleting master and starting again with a fresh copy
    #Warning this will delete any changes you have made on master
    git checkout upstream/master
    git branch -D master
    git branch master
    git checkout master
    git push --force origin master
    ```