Display the branch structure and other important events in the Git command line interface

To set up the display of the branch structure, tags and pulls in the command line interface first create the following “alias”

git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"

To display the branch structure, execute the following “alias”

git lgb

This will execute the above defined “alias” and display the most important events of the branch.

Press q to exit from the display mode to the $ prompt.

Include PBD files in ClickOnce deployment to show the line numbers in the Stack Trace

If there is an error in an application, the line numbers are only included in the Stack Trace when the PBD files are also in the application directory.

To include the PBD files in an application that was distributed with ClickOnce deployment you need to:

  • Right click the main project and select Properties
  • On the Build tab
    • Uncheck Optimize Code to make sure the line numbers in the Stack Trace match the source code
    • Click the Advanced… button at the bottom of the window
    • Set Debug info to full
      VS PBD 01

  • On the Publish tab click the Application Files… button
    • On the Application Files window select the Show all files check box in the lower right corner
    • Change the Publish Status of the PBD files from Exclude (Auto) to Include
      VS PBD 02
    • Click OK to save the changes

How to get rid of the boring unwanted picture in Skype

Since Microsoft purchased Skype there is an annoying, unwanted advertisement on the main page. If you are tired of seeing the same boring picture every time you turn on Skype

  • In the Tools menu select Change language,
  • At the bottom of the list click Edit Skype Language File,
  • In the Language File Editor click Save as and save the copy of your current language file with any name, like NoPicture.
    Skype will try, but for security reasons cannot save the file in the Skype folder, and it will offer an alternate location: c:\Users\[YOUR USER NAME]. This is perfect for us.
  • Open the Tools -> Change language menu option again,
  • Click the Load language file at the bottom of the list,
  • Select the file you just saved,
  • In the File menu select Sign Out to exit Skype,
  • Start Skype again (it will ask your password).

The picture is gone.

Branching and merging in Git

Branching and Merging are very powerful features in Git.

There are may branching strategies, my favorite is well explained at http://nvie.com/posts/a-successful-git-branching-model/

Pick any model you like and stick to it for a while to better understand and evaluate it. If you do not like that try another one.

In this model when we start to work on a new feature we

  • Create a new branch (let’s call it feature) based on the develop branch and switch to it.
    • git checkout develop
      git branch feature
      git checkout feature
  • Develop the new feature in the feature branch and add the changes to the repository.
    • git add .
      git commit -m "Feature is done in feature branch"
  • Before merging the changes of the feature branch back into the develop branch get the latest changes from the develop branch, apply your changes on top of them and test the application
    • git rebase develop
  • If there are merge conflicts, launch the Merge Tool. See Merging in Git with four panels in Windows  to set up and use a great merge tool.
    • git mergetool
  • It is possible that you will encounter merge conflicts in the same file multiple times. Just repeat the git mergetool command as many times as needed.
  • When you are done with merging, complete the rebase
    • git rebase --continue
  • Add and commit your changes in the feature branch
    • git add .
      git commit -m "Feature is tested in feature branch"
  • When you have tested the code of the new feature, merge it back to the develop branch.
    Switch back to the develop branch and merge the changes from the feature branch.

    • git checkout develop
      git merge feature
  • If there are any merge conflicts, Git will ask you to resolve them.

Merging in Git with four panels in Windows

Git is a great repository for small and large projects. It is easy to create and merge branches to separate code for the features you work on. To make merging easier you can use a free 4 panel merging tool, Perforce P4Merge.

Download

  • Download the Perforce P4Merge Visual Merge Tool from https://www.perforce.com/downloads/integrations
  • Select the operating system of your computer and click the Download button.

Install Perforce P4Merge

  • Double click the downloaded EXE file
  • Unselect the Administration tool
    P4Merge 01
  • Leave the server as is, we will not use it
    P4Merge 02
  • Just click OK, the address is not important for us
    P4Merge 03
  • Click Next again on the Client Configuration page
    P4Merge 04
  • On a Windows machine P4Merge will be installed at C:\Program Files\Perforce. Git cannot access P4Merge if the path contains a space character, so once the installation is done move the Perforce folder to the root of the C: drive.

Add the Perforce P4Merge settings to the Git config file

  • To use the same tool in every repository navigate to C:\Users\[YOUR USER NAME] and open the .gitconfig file.
  • If you already have [merge] and [mergetool “p4merge”] entries update them, if not, add the following lines. Even on Windows machines you have to use forward slashes (/) in the path for Git to understand it.
    [merge]
      tool = p4merge
    
    
    [mergetool "p4merge"]
      cmd = "C:/Perforce/p4merge" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
      keepTemporaries = false
      trustExitCode = false
      keepBackup = false

Solve merge conflicts

  • If you use the Git command line merge the branches. Git is case sensitive.
    • Change to the target branch
      • git checkout master
    • Merge the changes from the feature branch
      • git merge Feature
    • If there is a merge conflict type
      • git mergetool
    • Git will display the name of the file that caused the merge conflict
      • $ git mergetool
        Merging:
        Test1.txt
        Normal merge conflict for 'Test1.txt':
          {local}: modified file
          {remote}: modified file
        Hit return to start merge resolution tool (p4merge):
    • Hit Enter and the P4Merge opens with four panels
      • The left (Local) panel shows the changes in the current (target) branch,
      • The middle panel shows the original (Base) version of the file before both changes,
      • The right panel shows the coming changes (Remote) that were made in the branch you are merging from,
      • The bottom shows the result of the merge.
    • Change the file to resolve the conflict and click the Save button to save the result.

Merging is safe, because Git creates backup copies of all three version of the file in the same folder. If there are multiple files with merge conflicts Git will open the merge tool for each of them one-by-one.

  • Add the changes to the next commit
    • git add .
  • Commit the changes
    • git commit -m “Merged with P4Merge”

How to delete a folder from Git, but not from the local disk

I have accidentally included a folder in my Git repository, that I don’t want to include in source control. I wanted to remove it from the Git index, but not from the local hard drive.

The solution is the following command

git rm -r --cached myFolder

If the folder name contains spaces enclose it in quotes "my folder"

This will remove the folder from the Git repository, but leave it on the local drive.

Visual Studio 2015 is very slow on Windows 10

When I have upgraded Windows 7 my computer to Windows 10 I have also installed Visual Studio 2015 professional. From the first moment Visual Studio 2015 was very slow. My computer was freezing all the time.

I have read many articles about the slowness of Visual Studio 2015, but I cold not find anything that helped, so I have decided to switch back to Windows 7. Unfortunately after the downgrade process my computer did not boot anymore. Finally I had to reinstall Windows 7 and all my applications. Luckily all my files were on the hard drive, so I did not lose anything.

Since that, I have found the following recommendation at http://stackoverflow.com/questions/31760339/visual-studio-2015-slow

  • Uncheck [Tools->Options->General->Automatically adjust visual experience based on client performance]
  • Uncheck [Use graphics acceleration if available]
  • You can leave [Enable rich client visual experience] checked

Sooner or later I will have to bite the bullet and install Windows 10 again, hopefully by that time Microsoft corrects this very serious problem, or I will try these steps to make it work.

 

NUnit in Visual Studio 2015

To use NUnit in Visual Studio 2015

Create a unit test project and download NUnit from NuGet

  • Start Visual Studio 2015 and open or create a solution
  • In your solution create a new class library for your unit tests
  • Right click the unit test project and select Manage NuGet Packages
  • Type NUnit into the search field
  • Install
    • NUnit
    • NUnit Test Adapter
    • NUnit Runners

Create unit tests

Run the unit tests

DynDns update error

On Windows 8 and Windows Server 2012 the Dyn Updater cannot update the IP address if you set the IPv-4 Configuration to Automatic during installation. The log contains the following error messages:

daemon – WARNING – Unable to get IP addresses for …dyndns.org, will retry later.

frontend – WARNING – API request failed. Status: 500 Method: ipaddress.get

frontend – WARNING – API error: Error connecting to checkip.dyndns.org. Please verify your internet connection and try again.

To make the Automatic IPv-4 Configuration setting work

  • Open a web browser and get the current IP address by navigating to http://checkip.dyndns.com/
  • Open the Dyn Updater,
    • Select the  host you want to fix,
    • Click the Configure Selected Hosts button.
      DynDns01
    • Select Static Address for the IPv4 Configuration,
    • Enter the current IP address,
    • Click the OK button.
      DynDns02

    • Select the item again and click the Refresh Host List button.
      DynDns03

    • Select the item again and click the Configure Selected Hosts button.DynDns04
    • Select the Automatic IPv-4 Configuration and click the OK button.
      DynDns05

 

Value was either too large or too small for a UInt32 error message when checking files into TFS

When you try to check-in or shelve files in Microsoft Team Foundation Server (TFS) sometimes the following error message appears:

Value was either too large or too small for a UInt32.

Cause:

There is an unsaved file in the IDE.

Solution:

Click Save All in the tool bar and try to check-in the files again.