Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I send changes of git staged area for code review (to any code review tool)?

Tags:

git

git-commit

I learned that git has notion of different file states: 1. New 2. Modified 3. Staged 4. Committed

After searching a lot, what I have found is if I want to send for code review to any tool, I have to make commit to local repository and push it to some central repo set for code review (by any code review tool e.g. Gerrit).

Now, suppose file was in state A before starting code review process and it went through 10 more reviews rework i.e. 10 more modifications i.e. 10 more commits to local repository and finally file is in state B, which should finally be committed.

From state A to B 10 commits were done.

Assume of these 10, 4 commits were on same section / part of file.

So, finally, when I will push reviewed and accepted file's final state B to main central repository I will have to make 10 commits of which some intermediate commits took rework i.e. unwanted commits.

But I don't want those unwanted commits.

From what I can think is I am interested in final state B to be pushed to repository with only one commit.

So I am looking for any such approach / tool which allows git staged changes to be sent for reviewed. Reviewer will review. If he rejects and suggest some changes then I unstage previous changes. Apply suggested changes, stage those changes and again sent for review.

Thus finally when code reviewed accepts I will make single commit my staged changes and will need only single final push.

like image 574
Free Coder Avatar asked Dec 06 '25 01:12

Free Coder


1 Answers

It is not possible to push uncommited changes in a git repository. However you could use different branches to achieve what you want. You could work on a development branch, and make as many commits as you want. You can push them to a certain development branch on the remote server. After the reviewer accepts the changes, you can merge the commits into the main branch. If you want, you can use git rebase to merge the commits into one single commit.

like image 193
Misch Avatar answered Dec 08 '25 14:12

Misch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!