Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking in only parts of files

Is it possible to select which changes in a file you want to check in? For example, I have added two projects to a solution file, but I only want to check in one of them. Or I have done work in two parts of a file, but only one part is done and ready to check in. Ideally, I'd like to use the new diff-utility in 2012, and just select the parts I want to check in, but can I do that?

like image 404
AkselK Avatar asked Sep 07 '12 08:09

AkselK


2 Answers

My workaround (in VS2015) is:

  1. Shelve affected Files
  2. Delete Stuff you don't want to check in (maybe via compare with latest version)
  3. Check in
  4. Unshelve shelveset
  5. (In my case than VS-Merge-Tool opens to Restore changes you want (Previous checked in lines was not to merge))
like image 141
MichiBack Avatar answered Oct 22 '22 13:10

MichiBack


Unfortunately there is no way to do that in TFS natively. TFS will always check in the whole version of the current file and it will force you to save your changes before checking in.

This is possible with Git. Using Git, if you were to do the following:

  1. Add "line 1" to foo.cs
  2. Stage foo.cs via "git add foo.cs"
  3. Add "line 2" to foo.cs
  4. Commit foo.cs

Then only line 1 will be checked into the repository. Furthermore, you can integrate your local git repository using git-tf, a new open-source tool published by Microsoft. You can download that tool here or here. The downside of working with Git right now is that it doesn't have great VS integration.

like image 21
Taylor Lafrinere Avatar answered Oct 22 '22 14:10

Taylor Lafrinere