I am saving my work at night with a single commit for many files. I wonder if it would be better to commit for each file but this seems like a lot more work.
I have no problem with the way things are now but I plan to put my code on GitHub and I want it to be easy to understand.
I'm wondering what the rest of you who use git are doing. Also if you could kind of spell it out for me. I'm new to Git and I've been using TortoiseGit and gitk in Windows.
Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository.
One of these responsibilities is taking care of how changes are inserted into the VCS, creating a commit which purpose should reflect one change and one change only. Also known as an atomic change.
Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.
When to commit and what to commit is an art, and there are no black-and-white rules. That being said, there are habits that are easier to understand than others.
In general, I think you should optimize your commits for understandability - if you go back and read the diff for the commit, can you figure out what you accomplished in the changes?
If you want to be more specific, here's a long list of what I think are do's and don'ts:
"Easy to understand" means also:
git bisect
(ie each commit should represent a change in a task, which compiles and add an evolution or a new feature, and not a "checkpoint commit", which would make the git bisect
fails way too soon)See "understanding the Git workflow" for more: you need to differentiate:
So pay attention to the "fast-forward" merge that Git uses by default: don't forget to clean-up the history of branches you are about to merge that way into public branches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With