Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

2015-03-05

My first .gitconfig

I've recently started to use git on an everyday basis. Here's a couple of configurations that you may find useful, if you're just getting started:

[http]
 sslVerify = false
 postBuffer = 104857600
[push]
 default = simple
[user]
 name = James Bond
 email = bond.james@mi6.com
[color]
 ui = auto
[core]
 autocrlf = true
 excludesfile = C:\\Users\\james\\Documents\\gitignore_global.txt
[difftool "sourcetree"]
 cmd = 'C:/Program Files (x86)/WinMerge/WinMergeU.exe' -e -u -dl Mine -wr -dr Theirs $LOCAL $REMOTE $MERGED
[merge]
    tool = kdiff3
[mergetool "kdiff3"]
    cmd = 'C:/Program Files/KDiff3/kdiff3' $BASE $LOCAL $REMOTE -o $MERGED
[credential]
 helper = store

A couple of notes:

  • You set all of this in Git Bash using the git-config command.
  • Your ".gitconfig" file is usually found in the root of your user folder.
  • If you have pluralsight, you can check the Git Fundamentals course.

2012-10-09

svn:ignore for Visual Studio

Similar to other source control systems, you can add an ignore list of files that should not be under source control. In subversion, this is the svn:ignore property. If you are using Visual Studio and the VisualSVN plugin, this can be achieved in the following way:

  • Right-click the solution > VisualSVN > Properties...
  • Click on New... > Advanced
    • In the Property name drop-down select svn:ignore
    • In the Property value text box put the list of expressions you want to ignore, separated by the space character.
Here is an example (work in progress, probably this will have the same content as my .gitignore):

*.suo
*.user
*.dbmdl
*.resharper
aspnet_client
thumbs.db
bin
Bin
obj
Obj
TestResults
debug
Debug
release
Release


You'll end up with something like this (TortoiseSVN):


Edit (2014-02-20)

Fixed an error in my example, each entry must be in a single line.

Update (2014-05-21)

Updated list.

2012-09-07

Death to the .user!

A couple months ago, one of my VS solutions would just crash with a specific project. After a couple of hours, I've found the solution: close Visual Studio, delete all the "*.csproj.user" files, and reload the solution. My theory is that this was caused by TFS merges, since this solution had a few dozen projects and was frequently updated by various users, which in turn caused frequent conflicts. It's no wonder that these files are listed in .gitignore.

Note: this is basically a repost from my previous blog.

.gitignore for Visual Studio 2010

If you are using an IDE to develop your applications (who doesn't these days?), you have probably stumbled on a lot of files that are automatically generated which you don't really need to add to source control. If you are using Visual Studio and plugins/extensions (such as ReSharper and NuGet) these are quite some files.  The ".gitignore" file was designed to solve just that: putting it in the root of your source control directory will prevent "git add ." commands from adding those files/directories. My current file is based on this one from github, with extensions from this one from stackoverflow, and finally a line that I added for ReSharper user files.

You can download the file here (be sure to remove the ".txt" extension).

Note: this is basically a repost from my previous blog.

2012-09-04

Creating a GIT repository in Windows for cloud storage

One of the cool uses for cloud storage (such as Dropbox, SkyDrive or Google Drive) is as a git source code repository for your pet projects. Here's how to get started it in Windows.
But first, a couple of assumptions:

  • You have in your first machine a "Projects/Sandbox" folder with an existing project (e.g. a Visual Studio solution) and a "Dropbox" folder synched with the cloud; on the second machine a "Projects2" without any code and " Dropbox2" folder synched with the cloud. "dropbox" is the name of the remote repository.
  • You've previously added you git "bin" directory to your PATH environment variable.
  • You have Powershell installed (it's available for Windows XP or later). And yes, you could use the "classic" command prompt, but it's not as cool :) Really, if you're not familiar it's a good time to start using it.
So, launch Powershell and do the following:

# creating the remote repository
cd "C:\Dropbox\repositories"
git init --bare sandbox.git

# creating the local repository and first commit
cd "C:\Projects\Sandbox"
git init .
git remote add gdrive "C:\Dropbox\repositories\sandbox.git"
git add .
git commit -m "Initial commit"
git push dropbox master

# on a second machine, getting the repository
cd "C:\Projects2"
git clone -o gdrive "C:\Dropbox\repositories\sandbox.git"

Since I'm no expert on git, feel free to drop any comment about it Also, these instructions are adapted from this post, and mostly unchanged, as Powershell uses a UNIX-like syntax (actually, it uses aliases to do this, but you get the same result).

Edit (2012-09-05):
It seems that Google Drive has some issues syncing some files (e.g. HEAD and config) on Windows 7. The problem has been reported by other users. A workaround I found is to restart Google Drive when that happens, but that's not really interesting. I don't have these problems with Dropbox, though, so I recommend it instead. Haven't tested with SkyDrive yet.