Git for Visual Studio

Last updated: 2014-06-04

I want to start using an online source code storage.

Azure has recently come out with Team Foundation Service. This is really cool. You both get an IssueTrackingSystem as a TFS Project Template e.g. Scrum and VersionControlSystem e.g. GIT – all in the cloud. You can get a free trial. See more on TFS at the links in the bottom of this post.

What do I want with the code in the future? I don’t know. So I will start with BitBucket instead. BitBucket provides GIT as a choice of VCS.

With this blog you set up your private version controlled code repository (repo).

After having learned to setup your own repo then you might want to fork an opensource repo and contribute back to the community. Doing fork right is not straight forward read here to see a great forking workflow. GitHub has a more comressed forking workflow here.

If you, like me, is new to GIT – then you might want to read this great free eBook Git Succinctly from Syncfusion (and checkout other free eBooks in their library). Or another free eBook Pro GIT.

Git Succinctly Pro GIT

 

Tips

Git on Windows

Installation

How to integrate Bitbucket and Visual Studio?

Here is a summary:

  • Get Git for Windows. Download from Google. At time of writing version is 1.8.0. Start installing…
    • On screen “Adjusting your PATH..” – select “Run GIT from the Win CMD”
    • Continue with the installer untill end
    • You will find an intro in C:\Program Files (x86)\Git\ReleaseNotes.rtf
  • Sign up with BitBucket.
    • You will need your username and email for Git.
    • Create a repository with the name of your VisualStudio solution you want to add to BitBucket. This was not shown in the video!
  • Configure Git with your BitBucket info
    • Search for “GIT” to start GIT Bash. You get a $ prompt. Type (after $):
    • $ git config –global user.name “<username>”
    • $ git config –global user.email “<email>”
  • Setup VisualStudio
    • Tools – ExtensionMgr – Online Gallery – Search for “GIT” – Download GIT Source Control Provider, Install and restart VS
    • Tools – Options – SourceControl – Plugin selection – Select “Plugin: GIT Source Control Provider
    • You should by now also have Options – SourceControl – GIT options – There should be auto filled: “Path to GIT: C:\Program Files (x86)\Git\bin\sh.exe” and “Path to DIFF: diffmerge.exe”
    • If you select the option Use TortoiseGit style icon set, then you get colored icons in the SolutionExplorer opposed to standard VS2012 faded icons. See the image of SolutionExplorer below.
  • Add VS solution to GIT
    • Open a solution you want to add to source control
    • In SolutionExplorer
      • RightClick solution – Create Git Repository
      • RightClick solution – Git Pending changes
        • Select all files by checking the box left to “Status” – Enter a comment – Press Commit – Changes were just committed locally only.
        • Press Git Bash
          • $ git remote add origin https://&lt;username>@bitbucket.org/<ownerusername>/<solutionname].git //”origin” is an alias for the url that is chosen by you
          • $ git push origin master //Push code to BitBucket
          • => If error “Fatal: git-receive-pack not found” then you got the case wrong. Correct case with:
          • $ git remote set-url origin https://<username>@bitbucket.org/<ownerusername>/<solutionname%5D.git //If you didn’t get the case or spelling right in the first go
          • $ git push origin master //You should be prompted for password and the code should upload
  • Git UI’s plugging in to Git for Windows (Not in the video – skip this step for later)

Using the GIT vsx (not in the video)

  • SolutionExplorer with TortoiseGit style icons

GIT with Solution Explorer

GIT with Solution Explorer

  • RightClick in SolutionExplorer – GIT

GIT Menu in SlnExplorer

GIT Menu in SlnExplorer

  • When you choose Pending Changes,  select some file in the Changed Files list, then you can check in the files to GIT by pressing Commit. Remember to write a comment for your commit. Again changes are only committed locally.

http://visualstudiogallery.msdn.microsoft.com/63a7e40d-4d71-4fbb-a23b-d262124b8f4c?SRC=VSIDE

Pending Changes

  • Again you need to do some extra to push your local changes to BitBucket. Press Git Bash
  • Type $ git push origin master //Push code to BitBucket
  • Log in to https://bitbucket.org/ and verify your changes has been pushed out.
  • Your commit will appear as a new box with your comment inside in the history window.

History

History

  • x

GIT Links

TortoiseGit

The first time I had to GetLatest of a single file I gave up on GitBash and its cmdline. Instead the wanted to give TortoiseGit a go.

  • Exit Visual Studio and any Git tools.
  • Install TortoiseGit . Current version by 2013-03 is 1.8.1
    • In VS – Tools – Options – SourceControl – GIT options – There is now auto filled: “Path to TortoiseGit: C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe”
  • In SlnExpl you now have a Context menu below – Git (master) – Git Bash: Branch, Commit, Export and more….
  • In WindowsExplorer browse to the root of the VS solution that matches the root in your GIT repository. Then you get this impressive menu:

    WindowsExplorer Repository Root Context Menu
    WindowsExplorer Repository Root Context Menu
  • ongoing…

Issue Bug Tracking

TurtleTFS

TurtleTfs is a plugin for either TortoiseGit or TortoiseSVN using TFS as tracking system.

TurtleMine

TurtleMine is a plugin for either TortoiseGit or TortoiseSVN using RedMine as tracking system.

TurtleMine

Other IssueBugTrackers

(scroll to Available Issue Bug Track Plug-ins)

GIT with TFS

  • Connect to TFS in Azure using a Scrum project template and a GIT repository
    Connect to TFS in Azure using a Scrum project template and a GIT repository
  • The following procedure did not work – Somehow my VS TFS plugin is not configured to use GIT…
    Probably missing Visual Studio Tools for Git

    • In VS you can open TeamExplorer and
      • Connect to the server https://yourusername.visualstudio.com/DefaultCollection
      • Select the project e.g. “NewIdea”
      • Select Settings from TeamProject NewIdea dropdown list
      • Settings – Portal Settings – Project Portal – Enable – Use a website: https://yourusername.visualstudio.com/DefaultCollection/NewIdea
    • Go back to VS SlnExplorer – RightClick Sln – Add Solution To Source Control //Available if SourceControl is TFS.
    • Another try….
    • Goto https://yourusername.visualstudio.com/DefaultCollection/NewIdea
      • Click on Activity: Open new instance of Visual Studio
      • Open your VS project
    • x
  • Choosing Version Control in VS - TFS
    Choosing Version Control in VS – TFS
  • When you set up a webapp in Azure (via New WebSite – Custom Create) you can then choose to deploy from TFS.
    (click on the img to both get a demo of using EF Code First and how you create the SQL DB in Azure)

    Create Azure Web with TFS integration
    Create Azure Web with TFS integration
  • Various ways to deploy WebApps to Azure

The End

Advertisements

2 Comments

Add yours →

  1. Thanks you very much. This is the only Visual Studio+Bitbucket integration tutorial I could find on the internet.

  2. A list of GUIs:
    https://git-scm.com/downloads/guis

    GitHub Desktop (I think it also comes with GitHub shell):
    https://desktop.github.com/

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: