@@ -334,66 +334,26 @@ mode, you can find information on rebasing in the
334334
335335[ about-git-rebase ] : https://help.github.com/articles/about-git-rebase/
336336
337- The easiest method is to use the following command that compares the changes
338- in your branch to the ` master ` branch and shows you all the commits you have
339- made since in a text editor. You can select, drop, reorder and squash the
340- commits here.
337+ The safest method to squash your commits is to find out the last commit hash
338+ of the ` master ` branch with ` git log --oneline -n10 ` . Depending on the number of
339+ commits you made, ` -n ` can be bigger or smaller of course.
341340
342- ``` console
343- $ git rebase master -i
344- ```
345-
346- *** Note:*** This will automatically rebase your branch to the ` master ` branch
347- afterwards. If a lot of development happened on the ` master ` branch since you
348- have opened your Pull Request, a merge conflict might arise.
341+ You can then execute ` git rebase -i <last master hash> ` , which will show you
342+ all the commits you have made since in a text editor. You can select, drop,
343+ reorder and squash the commits here.
349344
350345If you used [ fixup commits] ( #add-fixup-commits-during-review ) during the review
351346phase, squashing commits can be performed in a single command:
352347
353348``` console
354- $ git rebase -i --autosquash master
355- ```
356-
357- If you want to remain on your branch and avoid possible merge conflicts at
358- this stage, you can set the starting point relative to the last commit, which
359- is called ` HEAD ` in git terminology:
360-
361- ``` console
362- $ git rebase -i HEAD~n
363- ```
364-
365- You have to replace the ` n ` with the number of commits you want to go back in
366- history.
367- You can find out how many commits you made by listing commits with the ` log `
368- subcommand. For example to show the last 10 commits, you can execute:
369-
370- ``` console
371- $ git log --oneline -n10
372- ```
373-
374- *** Watch out:*** Avoid setting ` n ` higher than the number of your commits as
375- this will add commits from the ` master ` history to your branch and therefore
376- create duplicates. If that has happened to you, you can manually run
377- ` git rebase master ` , which will sort out the duplicates again.
378-
379- If you encounter a merge conflict you could either resolve it by hand with an
380- editor and use
381-
382- ``` console
383- $ git add -p
384- ```
385-
386- To add your changes or use a merge tool like [ meld] ( https://meldmerge.org/ ) to
387- resolve your merge conflict.
388-
389- ``` console
390- $ git mergetool
349+ $ git rebase -i --autosquash < last master hash>
391350```
392351
393- Many modern editors and IDEs also feature graphical merge tools that will make
394- the merge process a lot easier.
352+ If you encounter a merge conflict, it is generally easiest to use a merge tool
353+ like [ meld] ( https://meldmerge.org/ ) or the built-in merge tool of your editor
354+ or IDE.
395355
396- After the merge conflict is resolved you can continue to rebase by using
356+ After the merge conflict is resolved you can continue the rebase by using
397357
398358``` console
399359$ git rebase --continue
0 commit comments