Loading gists…
A Text snippet, saved for reference.
| 1 | Fork and clone |
| 2 | ------------------------------------------------------------------- |
| 3 | git clone https://github.com/your-username/rms-test.git |
| 4 | cd rms-test |
| 5 | |
| 6 | git remote add upstream https://github.com/leafclutch/rms-test.git |
| 7 | git remote -v |
| 8 | |
| 9 | git switch -c feature/notification-apis |
| 10 | |
| 11 | # work on code |
| 12 | git add . |
| 13 | git commit -m "feat: add notification APIs" |
| 14 | |
| 15 | git fetch upstream |
| 16 | git merge upstream/main |
| 17 | |
| 18 | npm run dev |
| 19 | |
| 20 | git push origin feature/notification-apis |
| 21 | |
| 22 | One line summary |
| 23 | Fork → Clone fork → Add upstream → Create branch → Work → Fetch upstream → Merge upstream/main → Push to fork → PR |
| 24 | |
| 25 | ----------------------------------------------------------------------------------------------------------------- |
| 26 | |
| 27 | ----------------------------------------------------------------------------------------------------------------- |
| 28 | |
| 29 | ############################################ |
| 30 | # 🧠 Git & GitHub – Complete Command Flow |
| 31 | ############################################ |
| 32 | |
| 33 | ########## 1️⃣ Setup & Clone ########## |
| 34 | |
| 35 | # Clone a GitHub repository to local machine |
| 36 | git clone <repo-url> |
| 37 | |
| 38 | # Enter the project folder |
| 39 | cd project-name |
| 40 | |
| 41 | |
| 42 | ########## 2️⃣ Check Current State ########## |
| 43 | |
| 44 | # Show modified, staged, and untracked files |
| 45 | git status |
| 46 | |
| 47 | # Show commit history in short format |
| 48 | git log --oneline |
| 49 | |
| 50 | |
| 51 | ########## 3️⃣ Branch Management ########## |
| 52 | |
| 53 | # List local branches |
| 54 | git branch |
| 55 | |
| 56 | # List all branches (local + remote) |
| 57 | git branch -a |
| 58 | |
| 59 | # Switch to an existing branch |
| 60 | git checkout <branch-name> |
| 61 | |
| 62 | # Create and switch to a new branch |
| 63 | git checkout -b <branch-name> |
| 64 | |
| 65 | # Modern way to switch branches |
| 66 | git switch <branch-name> |
| 67 | |
| 68 | |
| 69 | ########## 4️⃣ Daily Start (Best Practice) ########## |
| 70 | |
| 71 | # Switch to master/main branch |
| 72 | git checkout master |
| 73 | |
| 74 | # Get latest stable code from remote |
| 75 | git pull origin master |
| 76 | |
| 77 | |
| 78 | ########## 5️⃣ Writing Code → Commit Flow ########## |
| 79 | |
| 80 | # Stage all changes |
| 81 | git add . |
| 82 | |
| 83 | # Stage a specific file |
| 84 | git add <file-name> |
| 85 | |
| 86 | # Save a snapshot of changes |
| 87 | git commit -m "commit message" |
| 88 | |
| 89 | |
| 90 | ########## 6️⃣ Push to GitHub ########## |
| 91 | |
| 92 | # Push a branch to GitHub |
| 93 | git push origin <branch-name> |
| 94 | |
| 95 | # First push (sets upstream) |
| 96 | git push -u origin <branch-name> |
| 97 | |
| 98 | # Push again after upstream is set |
| 99 | git push |
| 100 | |
| 101 | |
| 102 | ########## 7️⃣ Fetch vs Pull ########## |
| 103 | |
| 104 | # Download remote changes WITHOUT merging |
| 105 | git fetch origin |
| 106 | |
| 107 | # Download and merge changes into current branch |
| 108 | git pull origin <branch-name> |
| 109 | |
| 110 | # Pull with rebase (clean history – advanced) |
| 111 | git pull --rebase |
| 112 | |
| 113 | |
| 114 | ########## 8️⃣ Merging Branches ########## |
| 115 | |
| 116 | # Merge remote branch into current branch |
| 117 | git merge origin/feat/auth |
| 118 | |
| 119 | # Merge local branch into current branch |
| 120 | git merge <branch-name> |
| 121 | |
| 122 | |
| 123 | ########## 9️⃣ Merge Conflict Handling ########## |
| 124 | |
| 125 | # Check conflicted files |
| 126 | git status |
| 127 | |
| 128 | # Mark conflicts as resolved |
| 129 | git add . |
| 130 | |
| 131 | # Finish merge after resolving conflicts |
| 132 | git commit -m "resolve conflict" |
| 133 | |
| 134 | |
| 135 | ########## 🔟 Git Stash (Temporary Save) ########## |
| 136 | |
| 137 | # Save unfinished local changes |
| 138 | git stash |
| 139 | |
| 140 | # Save stash with a message |
| 141 | git stash push -m "message" |
| 142 | |
| 143 | # View all stashes |
| 144 | git stash list |
| 145 | |
| 146 | # Restore stash and delete it |
| 147 | git stash pop |
| 148 | |
| 149 | # Restore stash without deleting it |
| 150 | git stash apply |
| 151 | |
| 152 | |
| 153 | ########## 1️⃣1️⃣ After Branch Is Merged ########## |
| 154 | |
| 155 | # Switch to master and update it |
| 156 | git checkout master |
| 157 | git pull origin master |
| 158 | |
| 159 | # Delete local merged branch |
| 160 | git branch -d feat/profile |
| 161 | |
| 162 | # Delete branch from GitHub (remote) |
| 163 | git push origin --delete feat/profile |
| 164 | |
| 165 | # Force delete local branch (use carefully) |
| 166 | git branch -D feat/profile |
| 167 | |
| 168 | |
| 169 | ########## 1️⃣2️⃣ Safe Workflow (One Line) ########## |
| 170 | |
| 171 | # pull → create branch → code → add → commit → push → PR → merge → delete branch |
| 172 | |
| 173 | |
| 174 | ########## 1️⃣3️⃣ Common Real-World Safe Update Flow ########## |
| 175 | |
| 176 | # Save current work |
| 177 | git stash |
| 178 | |
| 179 | # Fetch latest remote changes |
| 180 | git fetch origin |
| 181 | |
| 182 | # Merge master into current branch |
| 183 | git merge origin/master |
| 184 | |
| 185 | # Restore saved work |
| 186 | git stash pop |
| 187 | |
| 188 |