Hello everybody! After a long time without any single post, I’m back here to give you an awesome tip. How to use git for your C# projects, and the best part, with Dropbox, so you can access your files wherever you are. (Ok, that’s a little too much).
Git is a tool to control revision and you can find everything in here, the official website.
For my C# environment I use Windows 7 and Visual Studio 2010, if you have the same, I totally recommend that you install a gitBash, it can be easily downloaded and installed from here.
From here I assume you have already prepared your develop environment.
First of all, I’d like to talk a little bit about gitignore (its manual can be found here). As you know, when you have a .NET project using VS, there will be a bunch of files that are modified every time you compile, build or run your project, so that will not be usefull for your control revision. There is where gitignore appears, with a single config file, you can set git to ignore those extensions, pretty easy huh?
Create a file called .gitignore (without any extention) in your root project folder.
I have checked over the internet and found the best C# gitignore configuration, you can copy and paste from here.
[Oo]bj/ [Bb]in/ *.user /TestResults *.vspscc *.vssscc deploy deploy/* *.suo *.cache
Alright, go to your folder using the gitbash, and start git:
$ git init
Now you are able to run your gitignore file using the next command line:
$ git config --global core.excludesfile ~/.gitignore
If everything went okay until here, you now have your project configured with git to ignore those files. Next steps I’m going to configure Dropbox to be your server. If you don’t have a Dropbox account, just go here.
Still using your gitbash, go to your project folder
$ cd ~/Desktop/MyApp
Then clone into an existing Dropbox folder.
$ git clone --bare . ~/Dropbox/AppFolder/my_app.git
--bare option tells git to not include the project files. Only those files needed to track the versioning are cloned (mainly those present in the
.git/ folder). See, another way to ignore those files mentioned before.
So far everything is pretty much configured, it’s important to create an alias for your pushs and pulls.
$ git remote add myApp ~/Dropbox/AppFolder/my_app.git
There you go! You are now able to use Dropbox as your git server.
You can also try a first commit typing:
$ git add .
$ git commit -m 'My first commit!'
And then a push by:
$ git push myApp master
And last but not least, a clone repository command:
$ git clone ~/Dropbox/AppFolder/my_app.git
Piece of cake!
Well, thanks for all the attention. I really hope that helps your over your projects. Any comments will be appreciated.