0

The branches of my colleagues has only 1 commit every time. Mine, includes all other commits I made like changes and fixes. How to do that? Or does it means they really commit only once before pushing it. They said rebase it onto master but I tried couple ways of procedure to do it but nothing happens.

I tried

1.)

git pull (master)
git checkout feature-branch
git rebase master

Then fixed the conflicts and nothing happens still all my commit history are there.

2.)

git pull (master)
git checkout feature-branch
git rebase --onto feature-branch <specific commit ID>

Still same

BGTabulation BGTabulate
  • 1,677
  • 3
  • 16
  • 39
  • 1
    Do you _mean_ 1 commit as asked (“ The branches of my colleagues has only 1 commit every time”) or do you mean when you create a pull request? It is not normal to have a repo with multiple different branches each containing one (implied, root) commit. It would help to show what you mean using git log. Please update the question to clarify. – AD7six Nov 01 '22 at 09:31
  • 2
    Assuming pull request workflow: Does this answer your question? [Preferred Github workflow for updating a pull request after code review](https://stackoverflow.com/a/15055649/761202) – AD7six Nov 01 '22 at 09:41
  • I have some issues understanding your question : "How to do that ?" does "that" refer to the fact that from what you see, your colleagues' changes are always grouped in one single commit ? Is your question: "How can I group all the changes on my branch in one single commit ?" – LeGEC Nov 01 '22 at 09:48
  • @AD7six this looks the answer for me. Yup exactly what I'm looking for thanks – BGTabulation BGTabulate Nov 01 '22 at 09:52
  • What do you mean? Of course your branch will still contain your commits – knittl Nov 01 '22 at 09:55

2 Answers2

1

Third possibilities comes to my mind:

You didn't complete the rebase in the last step. Follow the messages that git produce. After resolving conflicts, you should probably add, commit, and rebase --continue in order to complete. If you use git merge-tool for conflict resolution, only rebase --continue may be enough.

Second thing is, even after successful rebase, your old commit is still in the repository. It just becomes unreachable if there is no other tag or branch pointing to it. You can ignore that.

Last thing is, after your rebase, you should push or create a pull request and get accepted in order to be seen on the remote repository.

0

When you rebase, your commits will move to different parent. Your commits will get new SHA1 and will stay. Only their parent gets changed.

Please see the below diagram, where blue commits move to different parent and the history looks more cleaner.

image reference: https://developpaper.com/

enter image description here

Venkataraman R
  • 12,181
  • 2
  • 31
  • 58