4:14 - Monday, 21 April 2014

From TFS To Git

#Topics: git for tfs users

I’m a .NET developer and I’ve used TFS (team foundation server) as my source control software many times. Good features of TFS are:

  1. Good integration with Visual Studio (so I do almost everything visually; no console commands)
  2. Easy check-out, check-in process
  3. Easy merging and conflict resolution
  4. Easy automated builds
  5. Branching

Now, I want to use Git as the backbone, repository, and source control of my open source projects. My projects are in C#, JavaScript, or PHP language with MySQL, or SQL Server databases as the storage mechanism.

I just used github.com’s help for this purpose and I created a profile there, and downloaded a GUI for Git. Up to this part was so easy.

But I’m almost stuck at going along any further. I just want to do some simple (really simple) operations, including:

  1. Creating a project on Git and mapping it to a folder on my laptop
  2. Checking out/checking in files and folders
  3. Resolving conflicts

That’s all I need to do now. But it seems that the GUI is not that user friendly. I expect the GUI to have a Connect To... or something like that, and then I expect a list of projects to be shown, and when I choose one, I expect to see the list of files and folders of that project, just like exploring your TFS project in Visual Studio. Then I want to be able to right click a file and select check-in... or check-out and stuff like that.

Do I expect much? What should I do to easily use Git just like TFS? What am I missing here?

The advantages git has come from tossing out a lot of old assumptions about what a VCS should do. The disadvantages git has come from not being able to leverage prior experience and not being able to do things the way you are used to.

If you are going to switch from something else to git, try to start tabula-rasa (though it is impossible to truly do in practice). Evaluate it based on what it does and how well it does it, not on how it does it compared to how you are used to doing it. It’s not that you expect too much, it’s that your expectations are orthogonal to what git provides. If you’re married to GUI operation, you’ll be disappointed. Git does have gui tools available, but they don’t add much. That’s not a failure to provide them so much as there isn’t that much that a gui can add. GitK does help, not in day-to-day operations, but rather in visualizing the branch structure and examining or searching history.

Here’s a goofy analogy for what I mean by “orthogonal”. One of the things you can do with a newspaper is wrap fish in it, or use it to line a birdcage. But those are not essential to the function of a newspaper, those are incidental features of the form it comes in. Expecting git to “check in files”, or “allow you to select projects”, or provide a “connect to…” is kind of like expecting to be able to wrap fish or line your birdcage with a newspaper’s website.

Have you considered mercurial? Like git, it is a DCVS and lets you do all the neat things one can do with a DCVS. Like git there is a pretty good, cloud-based service provider (bitbucket). But, unlike git, the windows story is pretty decent, you are not a 2nd class citizen. You’ve got good tooling options (TortiseHG) and pretty decent Visual Studio integration (VisualHG).

Nothing is going to be like TFS in visual studio though — the world just isn’t wired that way.

I switched from SVN to git one year ago, and I’m very happy about it. However, I’m not relying on any GUI and in case you rigidly refuse command line it may be a problem.

You seem to expect git to work the way you’re used to, but it doesn’t. It’s not hard, but you should take a look at its principles before you proceed.

Creating a project on Git and mapping it to a folder on my laptop

Git is distributed, which means you always work with your local repository, which may be mapped to any number of remotes, including zero. When playing with other’s project I’m using two remotes: their git or SVN repository and my own server.

I always start by creating an empty directory and then either git init or git clone SOME-REMOTE-REPOSITORY. This link could help you.

Checking out/checking in files and folders

You missed to write what GUI you’re using. Both TortoiseGit and git-gui surely can do it.

Resolving conflicts

For this I’m using git-gui or my favorite text editor.

I expect the GUI to have a Connect To… or something like that

Connect to what, when there may be 0 to N remotes? Git doesn’t stay connected to a remote server, it creates the connection only temporarily and only for the few commands working with the remote repository. Most of the work gets done locally.

then I expect a list of projects to be shown

I’m assuming by projects you mean repositories.

I’m afraid there’s no such thing. Git on a remote server works strictly with one repository only. Listing all repositories is equivalent to listing all directories containing the subdirectory .git. I’m sure there’s something like this on GitHub.

I choose one, I expect to see the list of files and folders of that project, just like exploring

Again, I’m afraid there’s no such thing, since git works locally. And again, it wouldn’t be of much use. Simply clone the repository and explore it on your computer. While cloning of huge repos takes some time, all subsequent operations are much faster, and you may look at any commit or branch.

Then I want to be able to right click a file and select check-in… or check-out and stuff like that.

Again, git works locally. So it makes no sense to check-in or check-out to a remote repo. Working this way is a waste of time even on a fast LAN. Get the repository to your computer, work with it and git push the changes to the remote. Think about it like about publishing your changes and also making backup. You should commit locally very often.

Before you start your work, git fetch or git pull the changes from the remote in case somebody else may have been working with it.

Do I expect much?

Yes and no. You expect something different from what it offers. You can get something much better, git is powerful, flexible, safe, fast like hell, and can do everything you need, but it can’t mimic exactly what a centralized VCS does.

I have made the journy from visual source safe to tfs to svn to git.

Going from vss to tfs was a pleasant experience.
Going from tfs to svn was a pleasant experience.
Going from svn to git has been sort of an internal battle.

Often I find myself to be quite conservative and I try to hang on to what works.
A nice gui is for me preferable over the command line and I found myself searching for some gui that would let me play with the cool kids I work with. They all used git with the command line exclusively.

The eureka moment for me came once I gave up on the search for a silver bullet gui and started to give git bash a try (I’m still learning).

I have some guis installed and they do complement git from the command line.
Git extensions, Git source control provider for visual studio and tortoise git.
But I say get familiar with git bash.
The commands can be a little cryptic but once you learn them they are so much faster than the gui.

Branching with git is just AWESOME compared to the others.
Create branches and switching between branches it almost instant.
You can do stuff you would not bother doing with svn because svn basically copies your working copy (at least the way I did it).

I find Git to have a steeper learning curve than svn.
But once you “get it” with git you don’t want to go back.

Git all the way.

You’re used to having a server which stores your files and is the omnipotent owner of them. To edit a file you must ask for permission from the server.

Git is not like that. Think of git this way: you have your local repository. Git lets you commit changes, reverse commits, easy and quick branching, etc.
When you want to backup your source-control history, you push your changes to another repository, which “just happens to be” a server, like GitHub.com.

Workflow:

  1. Clone(Download)/Create repository
  2. Make some changes. Continue with development without caring about others.
  3. Push to another repository (could be a server like GitHub).
  4. When you push to a repository, that other repository’s owner is notified of the pending push, and must decide whether to accept those commits, decline them, or only take a subset of them.
  5. The cycle continues.

That is all.

What do you mean, “the” git gui? There are a gazillion of them, including a plugin for visual studio integration, if I remember correctly. If one GUI doesn’t work for you, try some more until you find one that does. I personally use different GUIs for different tasks (and the CLI for others).

However, git is more of a version control framework than a fixed system. You’re still going to have to learn some basics to get the most out of it.

GitHub has come to the rescue with regard to getting to use Git on windows, with gitHub For windows :)

all located at windows.github.com-

Both Hanselminutes and HerdingCode has had the Github team in for a chat on the podcast and Phil Haack (www.haacked.com) has blogged a few posts about it…

Look at the help to get more information….

Do I expect much?

Yes

What should I do to easily use Git just like TFS?

Nothing. Git is CLI-centric and haven’t any good frontend (I know about TortoiseGit, which is not answer, comparing to other Tortoise*). You can try to use SmartGit (beware of Java)

Share

Advertisement

Comment