I would like to understand why rebase is changing the order and the commits ID. Consider the following commit tree:
F1 -- F2 feature / M1 -- M2 -- M3 main There is another team commiting changes to main and pushing to remote and I need to catch up latest changes from main to feature, so I decided to use rebase as following:
myrepo git:(main) git pull origin main Now my local main branch contains the latest changes from remote (M3). Now I need to go to feature and do a git rebase:
➜ myrepo git:(main) git checkout feature Switched to branch 'feature' Your branch is up to date with 'origin/feature'. ➜ myrepo git:(feature) git rebase main Successfully rebased and updated refs/heads/feature. Checking my commits history:
d78c8d5 (HEAD -> feature) F3 775e06c F2 1cc4843 F1 31a5870 (origin/main, origin/HEAD, main) M3 9fd7263 M2 756c88d M1 eec81ba Initial commit The result is expected since rebase put all feature commits "after" main commits. The question is, if I run rebase without any arguments as following:
➜ myrepo git:(feature) git rebase warning: skipped previously applied commit 1cc4843 warning: skipped previously applied commit 775e06c hint: use --reapply-cherry-picks to include skipped commits hint: Disable this message with "git config advice.skippedCherryPicks false" Successfully rebased and updated refs/heads/feature. Besides the warning messages saying it will skip previously applied commits, it really changed the order and commits ID:
65ed33d (HEAD -> feature) F3 2b7e517 M3 7cea741 (origin/feature) F2 9c267ef F1 9fd7263 M2 756c88d M1 eec81ba Initial commit It seems something related to upstream, because now it is possible to run a push without the --force option.
➜ myrepo git:(feature) git push Enumerating objects: 11, done. Counting objects: 100% (11/11), done. Delta compression using up to 10 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (7/7), 641 bytes | 641.00 KiB/s, done. Total 7 (delta 1), reused 0 (delta 0), pack-reused 0 remote: remote: To create a merge request for feature, visit: What exactly is this "second time rebase" without argument doing? Why is it changing commits?"
git rebaseis documented to use your current branch's configured base, here that'sorigin/featureas usual. So that's what it did, it rebased your checked-out history on the defaultorigin/feature, and mentioned that some of the commits look like they were already cherrypicked there so it skipped them.