Super Quick Git Tutorial

Basic Usage Example For Working With Git

Vince Sesto
Splunk User Developer Administrator
3 min readMar 7, 2017

--

If you want to collaborate with a few other developers, you will either need to have a Git server running or be using a Git hosting service. In the example below we will be using GitHub as it’s one of the most popular available to use and is free if you don’t mind your repositories being public.

In the example below you will need to have Git installed on your laptop or PC to then connect and work with your GitHub repository.

GitHub Accounts

Most of the work below will be using the command line, but we first need to move to the GitHub website to create an account(If you don’t have one already) and create a repository.

  1. Start by creating an account on GitHub. Go to the following URL and create your own account: https://github.com/, if you don’t have one already.
  2. Take a little time to set up your account and add all your specific details and passwords.
  3. Make sure that you also set up SSH keys on GitHub as this will allow you to pull and push changes to and from the GitHub servers.

Create Your Repository

We are going to create and start working with a new repository called testrepo, so you should still be logged onto GitHub and run through the following:

  1. While you are logged into GitHub, in the top right hand corner of the screen, click on the + and select “New Repository”
  2. You will be presented with the screen above to give your repository the name testrepo and description and display it as Public or Private. When you are happy, click on Create Repository. We have somewhere to store our repository, but we still need to initialize our repository. This is where we will move to our laptop or PC and start working on the command line.
  3. Go to your development environment and create a directory that you want to be developing on.
  4. We will create a basic README.md file, so run the following command to create the README.md file and populate it with its first line:
    echo “# GitAppDev” >> README.md
  5. Then initialize your repository by running the following Git command:
    git init
  6. To see if there have been any changes made in your repository, run the status command where we should only see the README.md file that has been added:
    git status
    On branch master
    Initial commit
    Untracked files:
    (use “git add <file>…” to include in what will be committed)
    README.md
    nothing added to commit but untracked files present (use “git add” to track)
  7. As our output states we need to add our untracked file if we want to track it, so we then use the add command to allow Git to track our new file:
    git add .
  8. When we are happy with all our additions, then we can commit the changes have added:
    git commit –m “Our first commit”
  9. All this is still on our local Git application, on our laptop of PC, so let GitHub know we are going to add some more information. Get the URL for the repository you have created and run the following command(remember to substitute your GitHub username with the <username> below):
    git remote add origin git@github.com:<username>/testrepo.git
  10. Finally, push your changes back to the remote repository on GitHub:
    git push –u origin master

If you access the GitHub web interface again, you will be able to see the new files added to your repository.

Found this post useful? Kindly tap the ❤ button below! :)

About The Author

Vince has worked with Splunk for over 5 years, developing apps and reporting applications around Splunk, and now works hard to advocate its success. He has worked as a system engineer in big data companies and development departments, where he has regularly supported, built, and developed with Splunk. He has now published his first book via Packt Publishing — Learning Splunk Web Framework.

--

--

Vince Sesto
Splunk User Developer Administrator

Vincent Sesto is a DevOps Engineer, Endurance Athlete, Coach and Author. One of his passion’s in life is endurance sports as both an athlete, coach and author.