Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial File Commit in Team Foundation [duplicate]

Is it possible to perform a "partial" or "patch" commit in Team Foundation? I have a single file with two lines that have been modified, but I only want to commit one of those lines. Git has this functionality in the "git add -p" command. Does TFS have something similar?

My problem more specifically is: my .proj file has changes to the database connections settings that I don't want committed to TFS (since this is a connection to a development database on my own dev computer). However, I have deleted a file in the project, so I want to commit the removal of the reference from the .proj file. I'm using Team Foundation Server 11 and Visual Studio 2010.

like image 763
Adam Dunn Avatar asked Jun 14 '12 21:06

Adam Dunn


People also ask

How do I only commit part of a file?

git add -p And if you want to commit only parts of a file, you can use the interactive mode, which is turned on by the -p option. It continuously shows small portions of the changed files and asks you what to do. In each step, you can mark hunks, which is a nearby set of changes, for staging or to be ignored for now.

What is a partial commit?

Git partial commits allow contributors to encapsulate a single hunk* in a single file, disparate hunks in a single file, or many disparate hunks across many files into a single commit. This is useful for developers with ambitions to contribute discrete yet working change-sets in a single commit.

How do I add individual changes in git?

If the file is not in the repository yet, you can first do git add -N <filename> . Afterwards you can go on with git add -p <filename> . Afterwards, you can use: git diff --staged to check that you staged the correct changes.

How do you commit staged changes in Visual Studio?

When you stage a change, Visual Studio creates a Staged Changes section. Only changes in the Staged Changes section are added to the next commit, which you can do by selecting Commit Staged. The equivalent command for this action is git commit -m "Your commit message" .


1 Answers

No.

You can undo one of those changes, commit the remaining one, then reapply the change you didnt' want to go.

OR

You could shelve your current changes, make the change to delete the file, commit that then unshelve your change set and keep working.

like image 75
NotMe Avatar answered Sep 30 '22 20:09

NotMe