Git Good: Basics of Git

What is Git?

Git is a free and open-source version control system, created by Linus Torvalds in 2005. It allows multiple people to work on a project simultaneously without overwriting each other’s changes, maintaining a history of revisions.

For a straightforward guide, check out this no-sh*t guide.

How Git Works

Here’s a basic overview of how Git operates:

  1. Create a repository: Initialize a project repository with a Git hosting tool (like GitHub or Bitbucket).
  2. Clone the repository: Copy the repository to your local machine.
  3. Add and commit changes: Make changes to your local files and commit these changes to the local repository.
  4. Push changes: Upload your changes to the main branch on the remote repository.
  5. Pull changes: Download changes made by others from the remote repository to your local machine.
  6. Create a branch: Create a separate version of your project to work on new features.
  7. Open a pull request: Propose your changes to be merged into the main branch.
  8. Merge branches: Combine your changes with the main branch after approval.

Basic Git Commands

Creating a Repository

To initialize a new repository, navigate to your project directory and run:

Adding and Committing Changes

Or add all changes:

Commit your changes with a message:

Pushing to a Remote Repository

Add a remote repository URL (only needed once):

Push your changes to the master branch:

Pulling Changes

Download changes from the remote repository to your local machine:

Creating and Managing Branches

Create a new branch:

Switch to an existing branch:

Push a new branch to the remote repository:

Understanding these basic commands and workflows will help you get started with Git and improve your collaboration and project management skills. Happy coding!

Scroll to Top