Switching a Git merge workflow to rebase: how to clear merge history?

I am trying to create a good Git workflow for participating in an open source project (Endless Sky), but when I found out what I started, I did not finish with a clean history. Now my workflow:

  • upstream/master here .
  • My fork is here . I started using GitHub Desktop, but I'm starting to switch to the command line.
  • My master fork is supposed to mirror upstream/master. Each function I created has a branch for myself created by my master, and I use my own (local) branches alphaand (push) betato combine my functions for testing / playback.

My problem is on my forked host: This branch is 15 commits ahead of endless-sky:master.No files changed; it combines commit messages. It seemed ugly to me, so I did some reading, especially the article Stop using 'git pull': the best workflow , and I switched to reboot / fast forward.

But what is the best way to clear an existing merger to record history in this situation? It applies to some of my property branches (see:) feature/JammingHaywire, and I don’t want to submit a PR where meaningful commits are recessed by meaningless commits.

I read various other questions and don't quite understand if I am the best:

  • removal / recycling master- is it safe, especially with github?
  • git rebase -i [which commit?] - - , . 0facf00, , , (, 3be4d97, GitHub) , . .
  • - , ? , " " ?
+4
2

, master, , . :

  • , master:

    git checkout master
    
  • :

    git branch backup
    
  • Reset master, upstream. , , 1, :

    git reset --hard upstream/master
    
  • Force-:

    git push --force-with-lease origin master
    

    . , / , . , -, . , , .

master upstream/master, GitHub :

This branch is even with endless-sky:master.

, - , backup, .

, , :

git checkout myfeature
git rebase -i master

, . , , . --force-with-lease.

+1

: " 15 : ". ; .

:

reset /

, :

cd /path/to/fork/clone
git checkout master
git remote add-url endless-sky /url/of/endless-sky
git fetch endless-sky
git reset --hard endless-sky/master
git push --force

( PR) ( endless-sky/master)

git checkout my_feature_branch
git rebase master
git push --force
+2

Source: https://habr.com/ru/post/1665555/


All Articles