DEV Community

Dakota Lewallen
Dakota Lewallen

Posted on • Updated on

Git Essentials in Five Minutes or Less

What is Git?

Git is Source Control Management Software. It is a project management tool, with the goal of maintaining a digital projects history. It does this by tracking changes of the contents within a folder/directory. It also makes it easy to share projects remotely, across the internet, without having to transfer the entire project.

Vocabulary

  1. Repository
    • Location where changes are tracked.
  2. Commit
    • Set of changes to apply to the projects history.
  3. Branch
    • A collection of commits.

Commands

     user:~/project/tutorial$ git init
Enter fullscreen mode Exit fullscreen mode
     user:~/project/tutorial$ git add .
Enter fullscreen mode Exit fullscreen mode
  • This tells Git that you would like to track the history for all files and folders within this directory.
  • See git-add
     user:~/project/tutorial$ git commit -m "Initial Commit"
Enter fullscreen mode Exit fullscreen mode

You now have a repository that contains:

  • Any files within this folder.
  • A "master" branch.
  • A single commit with a message of "Initial Commit".

In order to add more changes, you should repeat the second and third commands any time you make changes to the contents of the folder.
Note: Make sure you change the message for your commits, because that will be the quickest way to tell what you changed with the commit.

     user:~/project/tutorial$ git revert <commit>
Enter fullscreen mode Exit fullscreen mode
  • Undo the changes recorded within a commit. Does not erase the original commit, merely undoes the changes that were recorded.
  • The commit must be done through a reference. You can find the hash(ID) for a commit by running "git log". You cannot specify a message.

More Information

This article is intended to be a quick and dirty introduction of the most basic concepts and commands to get up and running with Git. How to start a repository, how to add history, how to undo history. You can check back on this series for more in-depth guides in the future. As well as follow the links provided below for more information.


Find me on Twitter | LinkedIn
Sponsor me on Github
Like the article? Buy me a coffee!

Top comments (1)

Collapse
 
therealdakotal profile image
Dakota Lewallen

If there's any other topics related to git you'd like to see summarized. Let me know here. Next up will be branches. 👍