Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio TFS Git not seeing any changes

I'm not getting something about Visual Studio's Git for TFS.

I cloned a colleague's solution in Git on TFS and started adding code. I then realised that I needed my own branch for the changes I was making, and so following the instructions in Push a new local branch to a remote Git repo and track it too I ran

git checkout -b e4ctim git push -u origin e4ctim 

When I make changes to my code visual studio shows the familiar red-tick icon by the code file to reassure me that the change has triggered the file to be checked out:

VS red-tick

And then when I save the file the Visual Studio returns the icon to the blue padlock. I assume that this change from red-tick to blue padlock signifies that the change has been checked-in locally in Git:

VS blue-lock

But when I look at the history of the modified file, there is none!

No history

I would like to commit my changes locally and sync them with the TFS server.

Visual Studio does not see any changes at all:

VS TFS Changes

From the command line I can see that Git has noticed all of my modifications by running the command

git status 

and seeing lots of changes not staged for commit and untracked files.

git status cmd

Looing at the Git book I could use

git add 

or more specifically

git add -u . 

to stage the files ready for a commit but I'm reluctant to do that as the Develop your app in a Git repository (track, commit) Visual Studio documentation states:

Q: Where is the Git stage?
A: If you are an experienced Git user, you might have noticed that Visual Studio handles changes differently than the command prompt. You might have wondered if the Included Changes section contains your staged changes. In fact, Visual Studio usually bypasses the Git stage for you. When you commit changes, Visual Studio simultaneously stages and commits them. The one exception occurs when you add a file to your Git repository; Visual Studio does stage this kind of change.

Visual Studio stages and commits changes simultaneously. But why is it not listing any of the modifications I have made to tracked files as changes, and thus letting me commit them?

like image 686
dumbledad Avatar asked Feb 11 '15 12:02

dumbledad


People also ask

How do I see changes in Git Visual Studio?

As you do your work, Visual Studio keeps track of the file changes to your project in the Changes section of the Git Changes window. When you are ready to stage changes, click the + (plus) button on each file you want to stage, or right-click a file and then select Stage.

Does TFS work with Git?

git-tfs provides a two-way bridge between a local Git repository and a TFS server. git-tfs allows you to do your local development in a Git repository, and still synchronize your work with a TFS server.

How do I commit changes in Git using Visual Studio?

Just enter your commit message and then select Commit All. The equivalent command for this action is git commit -a . Visual Studio also makes it easy to commit and sync with one click by using the Commit All and Push and Commit All and Sync shortcuts.


1 Answers

This is more of a workaround than an explanation, but I found that if I ignored the documentation "when you commit changes, Visual Studio simultaneously stages and commits them" and instead added the modifications to staging with the command

git add -u . 

then Visual Studio suddenly became aware of the modifications and let me commit them locally and sync them with the TFS server. Moreover it then put the 'new file' green cross on the files I had added and I found I could do another commit and then another sync to pick up the additions and deletions I had made.

Since then Visual Studio is doing what I would expect: when I make a change to the file the file is listed as changed in the commit window.

I still do not know why Visual Studio failed to pick up the changes until after an initial git add but at least it works now.

like image 103
dumbledad Avatar answered Oct 06 '22 01:10

dumbledad