Git Starter Pack

Flare
3 min readAug 26, 2023

--

Intro

In this article, I would like to express my gratitude to a former colleague from my 1st position as a developer, during a phase of my career I had the privilege of being guided by her as she introduced me to the basics of Git.

What is Git?

Git is the rockstar of version control systems! you can think of it as a digital maestro that is conducting a symphony of source code, files… etc. which allows one to several developers to contribute to the same project simultaneously.

Terminology

  • Repository

commonly pronounced as“repo”, simply a folder that contains all the project files and history.

  • Commit

In one word “change”, is a way to track a project’s evolution and all the changes that have been made from day 0. Let’s say you want to monitor the growth of a plant by taking its picture every day, each picture represents a commit that shows the state of the project (the plant) at a specific time/day.

  • Branch

Think of it as a parallel universe of the source code where you can work on a feature or a fix without messing up the main code, in other words, it’s like having a VIP lab just for your experiments.

  • Merge

Say you want to combine different flavors of ice cream into a perfect blend of code through smooth transitions; Here we use “merge” and we combine changes from a different branch to the targeted branch, It’s like making sure your code sundae isn’t just vanilla but it’s got all the flavors in perfect harmony!

  • Pull Request (PR)

PRs are like sending out a code invitation where you’re asking, “Hey, can my changes join the main branch?” It’s a chance for code critique and collaboration before the big merge.

  • Remotes

They’re like having your repository’s twin on a faraway server, this way, you and your coding buddies can all contribute to the same project, whether you’re using GitHub, GitLab, or Bitbucket.

Workflow For Starters

  • Initialization

To start using Git, navigate to your project directory and run the command git init This will initialize a new Git repository.

  • Adding Files

Use git add <filename> to stage files for the next commit, staging prepares changes to be included in the next snapshot.

  • Committing Changes

Once files are staged, commit them using git commit -m "Your commit message" This creates a new snapshot with the staged changes.

  • Creating and Switching Branches

To create a new branch, use git checkout -b <branch-name> To switch between existing branches, use git checkout <branch-name>.

  • Merging

After completing work in a branch, merge it into another branch using git merge <branch-to-merge> You may need to address any conflicts that arise during the merge process.

  • Pushing and Pulling

To share your changes with others, push your local commits to a remote repository with git push To retrieve changes from the remote repository, use git pull.

  • Pull Requests and Code Review

If you’re collaborating with others, create a pull request to propose changes so that reviewers can provide feedback, and the changes are merged once approved.

References:

--

--

Flare

I write what I needed to read in the past | Opinions are my own.