2

I have just started using Git. From my previous experience from using Perforce, I want to know if i can stage the files in sections of user stories/tasks so that I can commit only specific files ? If so how to do this. I might be working on different user stories at the same time.

Regards, Pradeep

zilcuanu
  • 3,451
  • 8
  • 52
  • 105
  • [This section](http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository) of the Pro Git book should be illuminating. Also, you may find [this](http://stackoverflow.com/questions/25351450/what-does-adding-to-the-index-really-mean-in-git) useful. – jub0bs Sep 19 '14 at 07:09

1 Answers1

3

Yes, you can add to your index only specific file (git add -- afile).

But you even can add specific portion of a file (git add -p -- afile), up to a specific line.

In both case, adding to the index helps you to prepare the next commit.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • But there is a single index. Can i Have more sections in a single index? Or label specific files inside the staging area? – zilcuanu Sep 19 '14 at 06:50
  • 3
    @Pradeep no, you prepare one commit at a time. If your user stories can be developed independently one from another, you can consider branches (one branch per user stories, also called "feature branches") – VonC Sep 19 '14 at 06:51