Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git big commit best practices

Tags:

git

I'm using git and been working heavily on my local repository the last week.

I like to make many small commits (like 2 o 3 files) instead of big ones, but this time between time pressure and that the change involved many files, I've got a whole lot of files unstaged.

My question is, what is the best practice in this scenario? Is there any tool that lets me divide the work in small commits?

Note that I do know how to stage files one at a time and make the small commits by hand, but I'm afraid to make a mistake and create a commit that leaves the code in an inconsistent state (like not compiling or working badly).

Thanks!

like image 284
Pablo Fernandez Avatar asked Jan 21 '10 22:01

Pablo Fernandez


1 Answers

git add -i should help you divide commits to chunks, then git stash rest of code, check if everything works, git commit, git stash pop and loop.

like image 191
MBO Avatar answered Oct 13 '22 22:10

MBO