Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 881 Bytes

2-git-basics.md

File metadata and controls

50 lines (35 loc) · 881 Bytes

Get started with Git (local)

1. Install Git

2. Git - Basics

# Create a Git repo
mkdir git-demo && cd git-demo

# Initiate Git repo
git init 

# Update code: update 
touch file.txt 
echo "Hello Git!" >> file.txt
cat file.txt 

# Check Git status and save updates
git status 
git add file.txt 
git commit -m "My first Git commit"

# Create a branch
git branch dev

# Checkout to a new branch
git checkout dev 

# Update and commit
echo "My second commit" >> file.txt
cat file.txt 
git add . && git commit -m "Update file.txt: add a new line"

# Merge a `dev` branches to `main`
git checkout main 
cat file.txt

git merge dev
cat file.txt