So first off let me start by saying that I know that there is a ton of information out there on how to get started with Git. Heck, when you create your repo in GitLab it spits these instructions right out in front of your nose. However, what I have found is that most instructions tell you what to do to get started with git, however they do not tell you exactly what you are doing. You end up running a few command and then sit back and try to figure out what you actually just did.
That being said, getting started with Git has been the hardest part of the process, as most of us traditional grey-beard sysadmins are not that familiar with code management. When I was first getting started in technology, there were developers and there were sysadmins, and those two worlds were extremely separate. Now, we as we enter the age of DEVOPS and automation these two worlds are once again colliding (like they did in the beginning, but more on that another day).
In my lab I decided to build a stand alone vm for Git and Puppet. After doing some research – and asking others– on how and what to do to get Git up and running with a nice front end web interface, I decided to get started by installing the GitLab Omnibus package for Centos 6. This process was quick, easy, and painless.
Once I had a working webUI up and running it was time to create my first repo. Instead of trying to accomplish this from my Fedora workstaion, I just clicked on the "New Project" button on the GitLab dashboard and created an empty repo called "General_Scripts".
Back on my Fedora workstation I created a new directory in my home dir called git, and inside that directory I created a directory called "General_Scripts" as I had done in the webUI.
Now it was time to use Git.
First off you need to configure a few global Git options. This only needs to be done once.
#git config –global user.name "Fatmin"
#git config –global user.email "fatmin@fatmin.com"
Once these global configs are set you can then you can move on to seeding your repo. Here you see my change directories to the Global_Scripts directory and tell Git to initialize this directory as a repo.
#cd Global_Scripts
#git init
Now lets create a file and add it to the repo. Here were are going to create a simple README containing a description of my new repo. The instructions do not tell you that you have to put anything in this initial file, however what good is an empty README anyway
#vi README.md
Now tell git that this file needs to be added to the "General_Scripts" repo that we created a few steps ago.
#git add README.md
Now lets commit that file with a nice little comment. Commit comments should describe what the file we added or what we changed in an existing file
#git commit -m "Added README.md"
Now we need to tell our local git command what remote repo we are going to sync to. Note my git repo url is puppet.lab.localdomain, fatmin is my user's namespace, and General_Scripts is my repo.
#git remote add origin git@puppet.lab.localdomain:/fatmin/General_Scripts.git
Now we need to actually push the local files to the remote repo (origin) in the master branch.
#git push -u origin master
Now wait a bit and go check out the webUI. You should now see the README.md file in your new remote repo.
Related articles