While working on my web based learning project, I made a lot of changes to a Django view file without committing them. When I actually decided to commit, I realized that the changes in my view file should go into separate commits. I knew it was possible to commit parts of a file in Git, but I was not sure exactly how it could be done. I asked the question on StackOverflow and got an answer within minutes :-) Anyways here's how I did it. I had 3 files in my index: urls.py app/courses/templates/course/show.html app/courses/view.py The first 2 files were fine, but I did not want to commit the entire view file with the first two, I wanted only one change in that file to go in this commit. Since I had already added the view file to the index, I first had to unstage it with: git reset app/courses/view.py Then I did an interactive add to add only one hunk from the view file: git add --patch apps/courses/view.py Running this command showed me the first hunk from the file and an option ask...
Write Awesome User Manuals and Tutorials for Software Products