The Git Agenda

What is Git?

Most developers or beginners might have heard the term Git or GitHub in their learning phase. The git website itself mentions that it is "a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency".

Let's understand what the term "version control system" means. In the lifecycle of software development, many people contribute to its codebase or sometimes the same person can contribute many times. So a natural question arises, how does everyone know who contributed which part in the code or what new changes have been made recently? This is called versioning of source code. So now the phrase "version control system" starts to make sense.

Git Training Wheels:

  1. git init

The git init command initializes a new repository or reinitializes an existing repository. Create an empty Git repository in a specified directory. Run with no arguments to initialize the current directory as a git repository.

  1. git add [ . ]

Stage all changes in <directory> for the next commit. Replace <directory> with a <file> to change a specific file.

  1. git commit [ -m <message> ]

Commit the staged snapshot, but instead of launching a text editor, use <message> as the commit message.

  1. git status

List which files are staged, unstaged, and untracked.

  1. git log

Display the entire commit history using the default format. For customization see additional options.

Git Free Rider:

  1. git remote add <name> <url>

Create a new connection to a remote repo. After adding a remote, you can use <name> as a shortcut for <url> in other commands.

  1. git pull <remote>

Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy.

  1. git push <remote> <branch>

Push the branch to <remote>, along with necessary commits and objects. Creates a named branch in the remote repo if it doesn’t exist.