Git Workflow
๐ง DexaMinds Git & GitHub Training Guide (Using Git Bash)
๐ง 1. Initial Setup
โ Install Git
- Download from: https://git-scm.com/downloads
โ Configure Git
git config --global user.name "Your Name"
git config --global user.email "your.email@dexaminds.com"
git config --global core.editor "code --wait"
โ Verify Configuration
git config --list
๐ 2. Repository Management
โ Clone a Repository
git clone https://github.com/your-org/repo-name.git
โ Create a New Repository (Local)
mkdir my-project
cd my-project
git init
โ Link to Remote Repository
git remote add origin https://github.com/your-org/repo-name.git
git push -u origin main
โ Delete a Local Repository
rm -rf my-project
๐ฟ 3. Branching Operations
โ Create a New Branch
git checkout -b feature/branch-name
๐ Switch Between Branches
git checkout main
๐ Merge a Branch
git checkout main
git merge feature/branch-name
โ Delete a Branch
git branch -d feature/branch-name
git branch -D feature/branch-name
๐ 4. Commit Workflow
This section outlines the standard Git commit workflow that every developer at DexaMinds should follow:
๐งญ Step-by-Step Commit Workflow
-
Pull latest changes from the remote branch:
bash git pull origin branch-name
-
Check status of your working directory:
bash git status
-
Stage the changes you want to commit:
bash git add file-name git add .
-
Review staged changes (optional but recommended):
bash git diff --cached
-
Commit with a meaningful message:
bash git commit -m "feat: add login validation for user form"
-
Push your changes to the remote branch:
bash git push origin branch-name
-
Create a Pull Request on GitHub and request review.
๐ 5. Working with Pull Requests (PRs)
โ Create a PR
- Push your branch to GitHub.
- Go to GitHub โ Open your repo โ Click "Compare & pull request".
- Add title, description, reviewers, and submit.
โ Review a PR
- Use GitHub UI to comment, approve, or request changes.
โ Merge a PR
- After approval, click "Merge pull request" on GitHub.
๐งช 6. Best Practices
- Use meaningful branch names:
feature/login-page
,fix/api-error
- Commit often with clear messages.
- Always pull before pushing.
- Delete merged branches to keep repo clean.
- Use
.gitignore
to avoid committing unnecessary files.
๐ ๏ธ Common Git Commands Cheat Sheet
Action | Command |
---|---|
Initialize repo | git init |
Clone repo | git clone <url> |
Check status | git status |
Stage file | git add file-name |
Stage all | git add . |
Unstage file | git reset file-name |
Commit | git commit -m "message" |
Amend last commit | git commit --amend |
View commit history | git log |
View one-line log | git log --oneline |
Create branch | git checkout -b branch-name |
Switch branch | git checkout branch-name |
Delete branch | git branch -d branch-name |
Merge branch | git merge branch-name |
Pull changes | git pull origin branch-name |
Push changes | git push origin branch-name |
View remote | git remote -v |
Add remote | git remote add origin <url> |
Remove remote | git remote remove origin |