π Homepage π Syllabus of Day 2 β¬ οΈ Previous: β‘Resolving Merge Conflicts
1. Create and switch to a new branch
git checkout -b feature/my-feature
2. Make changes and stage them
git add .
3. Commit your changes
git commit -m "Add my feature"
4. Push your branch to GitHub
git push origin feature/my-feature
5. Open a Pull Request on GitHub
6. Review, resolve conflicts if any, and merge the PR
Command | Description |
---|---|
git branch |
List all local branches |
git branch branch-name |
Create a new branch |
git checkout branch-name |
Switch to a branch |
git checkout -b branch-name |
Create and switch to a new branch |
git switch branch-name |
Switch to a branch (newer syntax) |
git switch -c branch-name |
Create and switch to a new branch (newer syntax) |
git add filename |
Stage a specific file |
git add . |
Stage all changes in current directory |
git commit -m "message" |
Commit staged files with a message |
git push origin branch-name |
Push current branch to GitHub |
git pull origin branch-name |
Pull changes from remote branch and merge |
git fetch origin branch-name |
Fetch changes from remote branch (no merge) |
git merge branch-name |
Merge another branch into current branch |
git log --oneline --graph |
Visualize commit history as a graph |
git status |
Show current status (whatβs staged, unstaged, untracked) |
git diff |
Show unstaged changes |
git diff branch1..branch2 |
Show differences between two branches |
git remote -v |
Show remote repositories |
git clone repo-url |
Clone a remote repository |
git stash |
Temporarily save uncommitted changes |
| Command | Description |
|βββ|ββββ-|
| cd foldername
| Change directory |
| cd ..
| Go up one level |
| ls
| List files/folders |
| ls -a
| List all files including hidden |
| touch filename
| Create a new empty file |
| mkdir foldername
| Create a new directory |
| cat filename
| View file content |
| rm filename
| Delete a file |
| clear
| Clear terminal screen |
| pwd
| Show current directory path |
β
π‘ Tip: Use
git status
often to keep track of your changes
β‘οΈUp Next: πHands-On Exercise