I want to make sure my changes are safe when I add “some” of my changes and commit – push them to the branch. I am working on separate tasks and don’t want to add – commit – push yet for some.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, git is an excellent system for this workflow because of the “staging area” or “index”. So long as you don’t add
-atogit commit, only the files that you have added withgit addwill have their version updated in the next commit. (When you git commit, the tree that’s recorded in the commit is the state of the index.)In fact, you can do finer than per-file granularity – I frequently only stage some changes from a particular file by using:
… and just selecting particular changes. (If the changes it offers you aren’t fine enough, you can press s to split the change down. If that’s still too much, you can use e to edit precisely the change that will be staged.)
As you’re staging things, it’s helpful to frequently do:
git diffand:
git diff --cachedBroadly speaking,
git diffshows you the changes that haven’t been staged yet, whilegit diff --cachedshows you the changes that have been staged.