Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Tuesday, September 20, 2016

Why I still prefer using TFS vs. using Git

On all of my recent projects, I have been primarily using Git source control mainly because of the features for local feature branches for locally developing features and functionality without committing a branch directly to the main source control repository.

Of course, being a Microsoft developer, I am using Git within the Visual Studio IDE which presents its own challenges since Git support was added to the Visual Studio IDE very recently and mainly as an afterthought for functionality to cater to the needs of non-Microsoft-centric developers.

However, TFS is a platform which has been around for the last 11 years and has very robust and full-featured support within the Visual Studio IDE and provides many more features and functionality directly within the Visual Studio IDE.  In addition, many features are much more easily accessible and usable than with Git support in the Visual Studio IDE.


  1. First of all, Visual Studio has full support for viewing source control for TFS using Source Control Explorer directly within the Visual Studio IDE.  Unfortunately, while using Git, the developer is forced to browse to the repository within the browser in order to view source.
  2. Using Source Control Explorer within the Visual Studio IDE with TFS, you get much better visualization of the branching structure and how branches are interrelated to each other.
  3. Using Source Control Explorer within the Visual Studio IDE with TFS, you also have the ability to view "deleted" files from the TFS repository.  Using Git within the browser, there are no such options.
  4. Performing commits within TFS allows for meaningful commit numbers called "Changesets" which are easily understandable and can be readily remembered.  However, with Git, commits are very long random GUIDs which are neither easily understandable nor remembered.
  5. TFS allows committing just a single file even when there are other pending edits on your file system, while Git ALWAYS requires a commit and pull request before committing/pushing even a SINGLE file.
  6. Using Git within the Visual Studio IDE, only a very small portion of the total commands for using Git are available from a GUI interface.  All other operations require using a separate GIT client such as SourceTree or GitKraken or requires using the Git Command-Line client.  However, using TFS, nearly every operation is available within the GUI while only a few operations require using the TFS Power Tools through the command-line interface.
  7. Code Reviews within Git require a branching strategy and creating Pull requests from within the browser, while Code Reviews within TFS can be done on any committed code and are significantly easier and can be initiated directly from within the Visual Studio IDE.
  8. 3rd party merging and comparison tools such as Beyond Compare can be readily integrated into the IDE while using TFS, however, using Git only supports Visual Studio's built-in comparison and merging by default.  In order to support Beyond Compare for Git requires the installation of the Git Extensions for Visual Studio which still provides incomplete support at best.
  9. TFS allows "Shelving" support directly within the IDE as well as easily reviewing Shelvesets, however, Visual Studio has no built-in support for "Stashing" when using Git.  
So, even though Git is becoming increasingly popular to use as a source control repository, for Microsoft-based developers using the Visual Studio IDE, using Git over TFS presents some significant disadvantages that should be carefully weighed and considered before choosing Git over TFS as the de facto source control repository for your development team and organization.

Tuesday, September 13, 2016

Code Review in TFS vs. Git

If you are currently using Git with Team Foundation Server or Visual Studio Online, you may be wondering how the process of Code Reviews differs between the 2 source control platforms.

Well, they differ remarkably!

In fact, if you compare the TFS Code Review solution side-by-side with the Git Code Review solution, the TFS Code Review solution is FAR better and much more intuitive to use than the Git Code Review process.

Get your code reviewed with Visual Studiohttps://www.visualstudio.com/en-us/docs/tfvc/get-code-reviewed-vs

With TFS Code Reviews, you can easily review any set of code that exists in the TFS Repository which is extremely convenient!

However, with Git Code Reviews, you have to create feature branches and then create "Pull Requests" in order to get code reviewed before it is merged back into the main branch:

Review code with pull requestshttps://www.visualstudio.com/en-us/docs/git/pull-requests

Ideally, Microsoft would make the process of performing Code Reviews IDENTICAL between using Git or TFS Source Control!

If you also believe that Microsoft should make these 2 completely disparate processes consolidated within the Visual Studio IDE regardless of which source control system the developer is using, then you should vote for this UserVoice item here: https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/16046128-make-git-code-reviews-more-like-tfs-code-reviews


Wednesday, August 10, 2016

Handling spaces in Git Urls using TeamCity

If you are using Team Foundation Server/Visual Studio Online for your Git repository, there is a good chance that you may end up with spaces in your Git repository Url!

This is because TFS/VSO uses the Project Name as the method to generate the Git repository Url.

Unfortunately, this presents an immediate problem for TeamCity because spaces in Urls are translated as the %20 character!  Once you run a build in TeamCity with a Url containing these characters, the build on the build agent will fail with an error such as this:

"20Reports defined in VCS Root: VSO Reports"

Thankfully, there is a solution to this problem even though it is not perfect. To workaround around this problem, you simply escape the %20 characters with an additional % sign like so in your VCS Url:

VSO%%20Reports

This should resolve the issue with being able to execute a build with a VCS Url that contains spaces.

However, you may still end up with an error message like this in your build log beneath the Artifact dependencies:

Parameter "20Reports" is undefined

You can ignore this error message in the build log, but hopefully the Jetbrains TeamCity development team will fix this issue completely in the near future!




Monday, August 1, 2016

Why I still use SourceTree or GitKraken when developing with Git in Visual Studio

I have been using Git with Visual Studio regularly for the past several months and the deficiencies in Visual Studio integration with Git never cease to amaze me!

Below are just some of the errors/problems that I have faced while working with Visual Studio and
Git:








These error messages completely prevented me from performing any operations against Git.  Of course, I then switch over to an alternate Git GUI Client such as SourceTree or GitKraken and attempt to perform the same Commit operation and it works just fine!

In addition, Visual Studio integration with Git still lacks a very large number of Git commands such as Discard and various other commands which makes using an alternative Git client such as GitKraken or SourceTree an absolute necessity!!


Tuesday, July 26, 2016

Staged and unstaged files in Git using Visual Studio

Most developers have a common scenario of managing Web.config files among teams due to differing database connection strings.  If everyone is using a local instance of SQL Server or SQL Server Express, this might be able to be managed readily but if the connection strings are pointing to a shared server, this database connection string might change across development teams.  This issue is particularly prominent in offshore development teams whereby onshore and offshore development teams might need to use different database connection strings.

If you are using a source control repository such as Git, though, managing these individual changes among developers is a relatively easy task by leveraging Staged and Unstaged files!

Once you have a list of changes in Visual Studio Team Explorer, you can right click on one or more files to choose to Stage these files:





Once you have selected the files to Stage, you will end up with a list of Staged Changes and Changes (Unstaged Changes):


The files that are listed as Unstaged Changes will be excluded from being pushed to Git as follows by using the "Commit Staged" set of commands:


This allows isolated changes (such as those made to the Web.config file) to remain locally on developer machines while changes to other files can continue to be pushed to Git!

Wednesday, July 20, 2016

Visual Studio support for Beyond Compare with Git

If you have worked with Git inside of Visual Studio, you probably quickly discovered that the Git integration in Visual Studio does not provide support for any 3rd party tools such as Beyond Compare out-of-the-box (unlike TFS Integration).

But, as they say, where there is a will, there is a way!

Therefore, a clever developer has provided Git Extensions for Visual Studio: https://visualstudiogallery.msdn.microsoft.com/8f594baa-e44e-4114-8381-e175ace0fe97

This is further dependent on the installation of the Git Extensions project: http://gitextensions.github.io/

Once you have installed both of these tools, you will get a menu similar to the following:




Then, once you click on "Git Config" in the left hand navigation menu, you will get options similar to the following:



In this configuration, you can setup support for Beyond Compare!

Unfortunately, the integration is not quite complete with Visual Studio since when you open up the Repository Settings in Visual Studio, you will discover that only the "Merge Tool" displays as BeyondCompare4 while the "Diff Tool" still displays as Visual Studio.


Oh well!  Maybe they will fix this slight oversight in a future release of Git Extensions!

Also, if you want Microsoft to include support for Beyond Compare and other 3rd party diffing and merging tools, you should vote for this UserVoice item here: https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/13375314-allow-3rd-party-compare-tools-when-using-git-integ

Wednesday, July 13, 2016

Creating local branches in Git

If you ever want to do localized development and refactoring without requiring a special branch for the entire team, Git allows you to do that in the form of creating a local branch.

If you are a Visual Studio developer, Microsoft offers an article that provides insight on how to create local branches:

Creating work in Git Branches

https://www.visualstudio.com/en-us/docs/git/tutorial/branches

Now, if you want to merge that code BACK into Git, then you can use a command called Rebase as follows:

Managing history and merging changes with Git Rebase

https://www.visualstudio.com/en-us/docs/git/tutorial/rebase


In these Visual Studio articles, if you are looking for screenshots on how to do this, it may not be readily obvious where those screenshots exist.

When you get to the section in the articles where there are buttons for "Command Line" and "Visual Studio", you have to click on the Visual Studio button to expand the section including the screenshot:





Friday, July 1, 2016

Installing and configuring Upsource for Code Reviews

If you are using a source code repository such as Git hosted on BitBucket, GitHub or some other hosting provider, you will not get code review functionality built-in as you do when you are using a tool such as Team Foundation Server or Visual Studio Online.

Therefore, you need to rely on other solutions for performing your code reviews.  One such solution that exists for small teams is Upsource https://www.jetbrains.com/upsource/ (made by the same company that creates TeamCity and Resharper)!

Upsource is free for up to 10 users and then requires purchasing beyond 10 users.

One of the limitations of Upsource, however, is that it does not have a formalized installation package, thereby requiring a number of manual steps to get it installed and running.

Once you unzip the package, you have to run a command-line command in order to configure Upsource to run on your system: https://www.jetbrains.com/help/upsource/3.0/in-cloud-installation.html

Next, if you want to run Upsource as a Windows service, you also have to run several more commands at the command-line: https://www.jetbrains.com/help/upsource/3.0/starting-and-stopping-upsource.html

Then, once the Windows Service is installed, you will have to Start the Windows Service on the machine.

Finally, once you are able to browse to the Url for Upsource, you can begin configuring it for use with your source control repository.















Wednesday, June 29, 2016

Working with .gitignore files in Visual Studio

If you work with the .gitignore file in Visual Studio, you will notice that the Visual Studio IDE leaves a lot to be desired when it comes to ignoring files to add to the .gitignore file.

For example, you can only ignore items when they are first added to Visual Studio:


Of course, if you ever want to ignore additional files from Git AFTER  they have been added to the project/solution, Visual Studio offers no built-in method to accomplish this within the IDE!

Fortunately, the famous developer Mads Kristensen provides the .ignore Visual Studio Extension!  https://visualstudiogallery.msdn.microsoft.com/d0eba56d-603b-45ab-a680-edfda585f7f3

After installing this extension, when you then open the .gitignore file in Visual Studio, you will get nice syntax highlighting as follows:



Some of the nice features that it provides is browsing of directory paths in the .gitignore file:


It even provides path information to indicate when file paths that are listed in the .gitignore file do not exist:




Supposedly the grayed out text in the file points to invalid file paths, but, when I point to file paths that DO exist, in some cases, I end up with this instead:


So while this extension fills in a large number of gaps missed by Visual Studio, it has several limitations of its own.  Nevertheless, it is a handy tool to have around when working with your .gitignore files!

Friday, June 24, 2016

Windows Live Writer no longer works with Blogger!

I have been using Windows Live Writer for a very long time to manage my code snippets on my blog and when I logged into Windows Live Writer, I discovered that I could no longer log into Blogger!





It also seems that this problem has been reported by a large number of users from more than 1 year ago: http://answers.microsoft.com/en-us/windowslive/forum/writer-program/windows-live-writer-wont-connect-to-blogger/f3ae8ae5-f013-477b-b262-399430d29e28?auth=1

https://plus.google.com/u/0/+RickDoyle/posts/GUPJcu5sZHo

After discovering that Windows Live Writer is no longer actively maintained by Microsoft (the last release version was back in 2012), I started frantically searching for other code snippet tools that would work with Blogger.

One of the ones that I discovered was hilite.me (http://hilite.me/) as well as SyntaxHighlighter (http://alexgorbatchev.com/SyntaxHighlighter/integration.html), however, the sharing and formatting of the code snippets was not as nice as some other syntax highlighting tools such as Crayon Syntax Highlighter for WordPress (https://wordpress.org/plugins/crayon-syntax-highlighter/)

Fortunately, though, I finally came upon GitHub Gist! (https://gist.github.com)

I can easily embed a snippet of HTML that consequently embeds some JavaScript into the page which directly links to the code snippet on GitHub!

Even though I cannot directly preview the code snippet while editing my blog on Blogger, GitHub Gist offers an additional convenience allowing users to directly copy or download my code snippets for their own use!

This offers an additional level of code sharing with my users that I do not readily get with other tools, so I have decided to switch all of my new code snippets and samples over to GitHub Gist!!

Monday, June 20, 2016

Problems with Git Credential Manager

I recently started working on a Git project whereby I needed different sets of credentials for different Git repositories.

When I installed Git for Windows, I was presented with the following installation dialogs:















Unfortunately, as soon as I started working with my multiple Git repositories, I started getting prompted with this dialog repeatedly:


Therefore, it appeared that Git Credential Manager was the underlying culprit.  Therefore, I had to uninstall Git and when I re-installed Git, I made sure that I unchecked the following checkbox:



Then, instead of getting continually getting the Git Credential Manager dialog, I was just presented with this dialog a single time which also allowed me to select "Remember my credentials":



That was all that was needed to resolve this problem!!