Sometimes, when fixing some bugs, we need to commit repeatedly, and then launch a pull request, there will be a lot of commit numbers. Some companies will ask to merge these commits. At this time, we can use square to merge the committed commits
-
First, use git log to view the submitted records
git log commit 7e1c7e33c328f9c1fc954790386b14978612a30f (HEAD -> newbranch) Author: yuanjie111 <[email protected]> Date: Sat Jun 12 13:55:58 2021 +0800 111 commit 3a30ba5c71349947e512c6b0c481854a19418d10 (origin/newbranch) Author: ** Date: Sat Jun 12 13:03:01 2021 +0800 config center commit 2873ff1b3c92e9a4b0c4937a5a4a27d5178efe2b Author: *** Date: Sat Jun 12 12:48:29 2021 +0800 config center commit ba62f39480360977e08f6e1e288869f2fe4a7ed8 Author: *** :...skipping... commit 7e1c7e33c328f9c1fc954790386b14978612a30f (HEAD -> newbranch) Author: **** Date: Sat Jun 12 13:55:58 2021 +0800 111
-
Then use git rebase – I head ~ < number >
git rebase -i HEAD~10 //Head ~ 10 means tracing 10 records from the head
Keep the commit that needs to be left in the pick state, and change the commit that needs to be merged to s, as shown in the figure below. Only one commit is retained,
Then: WQ exit
3. Push to origin completes the merge.