Navigation: » Latest version
Owner: User #1179751
Git For Visual Studio Users
As an essentially new Git user (and a lazy one, who prefers using GUIs over CLIs), I've found that the following workflow seemed to be the easiest one to pick up:
Prerequisites: |
- Install Visual Studio:
(2010: "\\FS-01\share\Windows Software Development Resources\Visual Studio 2010") (2011: "\\FS-01\share\Windows Software Development Resources\Visual Studio 2012")
- Install Git Extensions:
("\\FS-01\share\Windows Software Development Resources\git\git Extensions")
- Launch Git Extensions on your development machine. After choosing your preferred UIUser Interface language, you
should have to configure some basic settings:
-
You will probably have to configure Git to ignore SSLSecure Socket Layer certificate errors (boo!).
You'll need to open the following config. file: "C:\Users\<Username>\.gitconfig" ...and then add the following lines:
For more info, see here: SSL certificate is invalid
|
Preparing your first commit – setting up your ".gitignore" file: |
So you've got some code written? Excellent! Let's get your repository set up to receive it.
- First, open Git Extensions and bring up your repository again:
- Click the large "Commit" button (circled below):
It should bring up a window that looks like the following:
Unfortunately, if you look closely, you'll see that there's a ton of log files, and temporary files, and object code files, and debugging symbol files, and stuff like that. Watch out – we certainly don't want to check those in!! Follow along to figure out how to get rid of them
- If you right-click on any of the undesirable files (I chose the first 'tlog' file, below), you should bring up a context menu
with a very helpful option: "Add file to .gitignore". For example:
- After clicking on that option, the "Add files(s) to .gitIgnore" (sic) dialog box comes up:
One nice thing about this dialog box that you can edit the file pattern in the upper box, and it will show you all of the files that match said pattern in the lower box. For example, I don't just want to ignore "Common/Debug/cl.command.1.tlog" – I want to ignore all of the ".tlog" files. So I'll type in a wildcard pattern: " *.tlog ". Now the dialog box looks like this:
-
In fact, you can enter patterns on multiple lines. You can even paste in an entire file! (Like the Visual Studio .gitignore file I found on Stack Overflow! Here it is below, after I sorted a few things and added comments.)
# OSOperating System junk files:
#
[Tt]humbs.db
*.DS_Store
# Build output files:
#
*.exe
*.dll
*.lib
# Visual Studio project files:
#
*.vcxproj.filters
*.user
*.aps
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.sbr
*.sdf
*.opensdf
ipch/
[Oo]User #?/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
# Visual Studio build files:
#
*.idb
*.pch
*.pdb
*.ipch
*.tlog
*.lastbuildstate
*.unsuccessfulbuild
*.[Oo]User #?
# MonoDevelop
#
*.pidb
*.userprefs
Ankh.NoLoad
# Tooling
#
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*
*.sass-cache
# Project build files:
#
[Bb]uild/
# Subversion and SourceSafe files:
#
.svn
*.vspscc
*.vssscc
# Office temp. files:
#
~$*
# Vim temp. files:
#
*~
# NuGet:
#
packages/
*.nupkg
# ncrunch
#
*ncrunch*
*crunch*.local.xml
# Visual Studio database project files
#
*.dbmdl
# Test files
#
*.testsettings
After pasting the entire file into the dialog box, mine looked like this:
I clicked "Ignore", and then I had a much more appropriate-looking list of files to check in:
The next set of instructions will cover using Git Extensions to "stage" things, and commit them to the repository.
|
Executing a commit – staging files and committing them to the repository: |
It's important to remember that Git makes a distinction between "staged" and "unstaged" files.
For example, maybe you modified 20 files in your project, but you only want to commit 10 of them. (Perhaps you're still working on the other 10, and they're not ready to commit yet?)
Git allows you to check in only the subset you're interested in – this process is called "staging" files before a commit. In Git Extensions, you stage and commit files as follows:
- First, I've opened the Commit windows I've selected all of the files I want to commit (in my case, all of them, because this is my initial check-in),
and now I'm about to click the "Stage" button, (circled below) :
- After clicking the 'Stage' button, the Commit window now looks like this:
- The next thing we're going to do is very important – we need to write a "Commit message". Always write a Commit Message!
(How come? Because five months from now, when your project is in testing, you – or someone else! – may need to go back through the project history and answer a question like, "Why on earth did we edit SecureHeapMgr.cpp back in December???")
You can write a commit message in the following field:
-------------------------------------------------------------------
|