Creating Local Git Repositories – Yeah, it’s that simple!
We’re in the process of evaluating several source control systems here at the office. It’s a JOYOUS experience and I mean that… sorta. Currently, we have a montage of files dumped into two SourceSafe repos.
At this point, most of you are either laughing, crying, or have closed your web browser so you don’t get caught reading something with the word ‘SourceSafe’ in it. That’s cool, I get that.
As part of my demonstrations (for the various toolings we’re looking at), I wanted to show how simple it was to create a local GIT repository.
Since I’m discussing ‘local’, I’m taking a lot of things out of the picture.
Authentication/authorization is handled by Windows file permissions/Active Directory. If you can touch the repo and read it, then knock yourself out.
Everything is handled through shares, no HTTP or that goodness. Users are used to hitting a mapped drive for SourceSafe repos, we’re just emulating that.
So what do we need to do to create a Git repository? Three easy steps (commands).
1. Create your directory with the .git extention.
2. Change into that new directory.
3. Initialize the repository using Git.
Our new Git repository is now initialized. You can even see that PowerShell picks up on the new repository and has changed my prompt accordingly.
Now that we have example.git as our ‘remote’ repository, we’re ready to make a local clone.
git clone H:\example.git example
Now we have an empty clone (and it’s kind enough to tell us).
All of our Git goodness is packed into the standard .git directory.
To test things out, let’s create a quick file, add it to our repo, and then commit it in.
First, let’s create/append an example file in our clone.
(note: this is called ‘so lazy, I don’t even want to open NotePad’)
Now, we can add and verify that our newly added ‘example.text’ file shows up:
git commit -a -m “this is our first commit”
… and push!
git push origin master
The last step is to ensure that our new ‘remote’ repository can be reproduced. Here’s a quick single line to clone our repository into another new folder, list out the contents, and verify the log has the commit we made in the first repo.
It’s amazing how quick and easy it is to setup local Git repositories. From here, we can look at the file system/Windows for authentication/authorization and focus on our migration AWAY from Visual SourceSafe.🙂