Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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?

share|improve this question
    
Note that I have deliberately not tagged this git yet as it seems peculiar to TFS and Visual Studio's Git workflow. – dumbledad Feb 11 '15 at 12:47
    
Are the files located under Team Explorer - Changes / Untracked files? – Magnus Karlsson Jul 8 '15 at 17:28
    
In the Visual Studio "15" preview, it now does use git's stage. – Joey Adams Apr 18 at 3:42
up vote 32 down vote accepted

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.

share|improve this answer
2  
Saved me already twice :) – Darxis Apr 4 '15 at 22:54
1  
Worth an upvote for all the efforts. – Vhortex Jul 9 '15 at 6:39

I had to add this line to my .gitignore:

[path to project]/node_modules/

Apparently VS2015 was crashing on some very long path in there and would just decide to give up all hope

share|improve this answer
    
Agreed. I just had this problem with an angular project. VS was choking on the node_modules and bower_components path and failing silently. – SouthShoreAK Jan 19 at 22:43
    
thanks you to you I won't turn crazy! – Nock Jan 24 at 12:01

I had the same probem and I realized the following: In order to show the changeset, As @dumbledad said, Visual Studio runs the command

git add -u 

internally for staging the updates. If some of the files that you are trying to add to your changeset is open by another process, then the git command gets a permission error. And Visual Studio won't show the changes.

In my case, I had a document in my repo that was open by another application, and that caused Visual Studio not to show the modifications because of the Git permission error. So check if any of the files of your git repository is not open by any other application.

share|improve this answer

I'm using VS 2015 Update 1 and also meet this problem. Furthermore, at the same time, the VS' output window told me my VC.opendb file under the solution folder is occupied by another program. According to this, I fixed the issue of occupying: add *.VC.opendb and *.VC.db to the .gitignore file. Then everything goes well.

share|improve this answer
    
This worked for me. Thank you for your answer. – Joao Milasch Jul 11 at 17:43

I had this problem on a new machine with a fresh install of both VS2013 Update 5 and VS 2015 and it was driving me crazy. Then I found if I installed Git for Windows, the problem went away! https://git-for-windows.github.io/

share|improve this answer

Then i was trying to make changes but files doesn't get effected...There is a easy solution for this. The major problem is one of your git ignore files ignoring your files..

Open your local repo for instance D://repos, then look file you want

--> D://repos/project1/HomeViewModel.cs

--> Right click on it and click on Git Extentions

--> Choose +Add Files

enter image description here

--> then Force option

enter image description here

--> Click on Addfiles..Here you go you file will be added in changes

share|improve this answer

I was having the same issue with Visual Studio Update 3. VS was saving locally but not picking up any changes so I couldn't commit.

I downloaded Git for Windows from https://git-for-windows.github.io/ (thanks @fhilton), opened the Developer Command Prompt and changed directory to C:\Repos\Scheduler (the location of my source code).

I then ran GET ADD -U and received the following error...

error: open("WindowsServices\Scheduler.WindowServices.InstallLog"): Permission Denied

error: unable to index file WindowsServices\Scheduler.WindowServices.InstallLog

fatal: updating files failed

As others have said, it looks like the GIT tools in Visual Studio can fail silently, even for the most basic Windows level errors. Worse, it can tell you GIT is fully in sync. Command line is certainly your friend for the time being.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.