DEV Community

Cover image for Git Adventures --- Part 1: Five Developers, One Repo, and the "It Works on My Machine" Era
Amaresh Pati
Amaresh Pati

Posted on • Originally published at blogs.devvloper.in

Git Adventures --- Part 1: Five Developers, One Repo, and the "It Works on My Machine" Era

Every software project begins the same way.

Someone says "Let's build something amazing."

Ten minutes later someone asks:

"Wait... who created the Git repo?"

This is the story of a five-person development team starting their first
project together.

Meet the team.

Virat --- The Repo Master
Responsible for repositories and access control.

Amaresh --- The Architect
Designs the project structure and keeps the codebase organized.

Johnny, Danny, Ronaldo --- The Feature Crew
Three developers who will build features, write code, and occasionally
break things.

Today is Day 1.

And the project begins with the most important step in any software
project.

Creating the repository.


Chapter 1 --- The Repo Is Born

Virat opens his terminal and announces that the project officially
begins.

mkdir project-hyperdrive
cd project-hyperdrive
Enter fullscreen mode Exit fullscreen mode

Now he initializes Git.

git init
Enter fullscreen mode Exit fullscreen mode

Git responds:

Initialized empty Git repository
Enter fullscreen mode Exit fullscreen mode

Behind the scenes something important just happened.

Git created a hidden folder called:

.git
Enter fullscreen mode Exit fullscreen mode

This folder stores everything Git needs:

  • commit history
  • branches
  • logs
  • references
  • repository metadata

Without .git, the folder is just a normal directory.

With .git, it becomes a version-controlled project.


Chapter 2 --- The Architect Builds the Foundation

Virat turns to Amaresh.

The repository exists now, but a repository without files is like a city
without buildings.

Amaresh prepares the initial project structure on his machine.

He checks what Git sees.

git status
Enter fullscreen mode Exit fullscreen mode

Output:

Untracked files:
README.md
src/
config/
Enter fullscreen mode Exit fullscreen mode

Git sees the files but does not track them automatically.

Developers must tell Git which files should be tracked.


Chapter 3 --- Connecting the Two Worlds

Virat created the repository on his machine, and Amaresh prepared
the project on his laptop.

Johnny asks:

"How are we working in the same repository?"

Virat explains.

Local Repository → developer machines
Remote Repository → shared server
Enter fullscreen mode Exit fullscreen mode

Virat connects his repository to the remote server.

git remote add origin https://company-repo/project.git
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

Amaresh connects his machine to the same repository.

git remote add origin https://company-repo/project.git
git pull origin main
Enter fullscreen mode Exit fullscreen mode

Now both machines share the same Git history.


Chapter 4 --- Teaching Git What to Remember

Amaresh stages the project files.

git add .
Enter fullscreen mode Exit fullscreen mode

The dot (.) means add everything inside the current directory.

Git workflow:

Working Directory → Staging Area → Commit History
Enter fullscreen mode Exit fullscreen mode

Staging allows developers to choose which files should go into the next
commit.


Chapter 5 --- The First Commit

Amaresh creates the first commit.

git commit -m "Initial project setup"
Enter fullscreen mode Exit fullscreen mode

A commit is a snapshot of the project at a specific moment.

Each commit records:

  • changes
  • author
  • time
  • commit message

Chapter 6 --- Sharing the Repo With the Team

Virat grants repository access to the team.

Johnny clones the repository.

git clone https://company-repo/project.git
Enter fullscreen mode Exit fullscreen mode

Danny checks the status.

git status
Enter fullscreen mode Exit fullscreen mode

Output:

On branch main
Your branch is up to date with origin/main
Enter fullscreen mode Exit fullscreen mode

Everyone is synchronized.


Chapter 7 --- The Branching Rules

The main branch must always remain stable.

Developers create branches for their work.

Feature

feat/login-system
feat/payment-module
Enter fullscreen mode Exit fullscreen mode

Bugfix

bugfix/login-validation
bugfix/crash-on-start
Enter fullscreen mode Exit fullscreen mode

Hotfix

hotfix/security-patch
hotfix/payment-crash
Enter fullscreen mode Exit fullscreen mode

Chore

chore/update-dependencies
Enter fullscreen mode Exit fullscreen mode

Docs

docs/setup-guide
Enter fullscreen mode Exit fullscreen mode

Refactor

refactor/auth-module
Enter fullscreen mode Exit fullscreen mode

Style

style/code-formatting
Enter fullscreen mode Exit fullscreen mode

Test

test/auth-tests
Enter fullscreen mode Exit fullscreen mode

Performance

perf/query-optimization
Enter fullscreen mode Exit fullscreen mode

Release

release/v1.0
Enter fullscreen mode Exit fullscreen mode

Workflow:

Create branch → Commit → Push → Pull Request → Review → Merge
Enter fullscreen mode Exit fullscreen mode


Chapter 8 --- The Feature Crew Begins

Amaresh assigns tasks.

Johnny:

git checkout -b feat/authentication
Enter fullscreen mode Exit fullscreen mode

Danny:

git checkout -b feat/profile-system
Enter fullscreen mode Exit fullscreen mode

Ronaldo:

git checkout -b feat/service-integration
Enter fullscreen mode Exit fullscreen mode

Three developers.

Three branches.

One repository.

And somewhere in the future...

A merge conflict is waiting.


End of Part 1

What the team learned:

  • git init
  • git status
  • git add
  • git commit
  • git remote
  • git push
  • git clone
  • git branch

Branch naming examples:

feat/
bugfix/
hotfix/
docs/
chore/
refactor/
style/
test/
perf/
release/
Enter fullscreen mode Exit fullscreen mode

What Happens in Part 2

In the next part the team will learn:

  • PR creation
  • git log
  • git diff
  • git show
  • git stash
  • resolving merge conflicts

Follow the series for Part 2.

Top comments (1)

Collapse
 
yash_shinde_0e171e07dee74 profile image
Yash Shinde • Edited

Amazing article !! Easy to understand too. Looking forward to pt 2