Git Workflows
This page is about the Git commands that a tester meets after the basics. It starts with how teams keep branches at levels of stability. Then it explains rebase, cherry-pick, stash, worktrees, and git bisect, with a practice run that finds a known bad commit twice. It builds on Git Basics.
11 min read11 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 14 sources14টি সোর্স · updated Nov 2026আপডেট: Nov 2026
Merge or rebase the same workএকই কাজ merge বা rebase করুন
Replay the same two commits both ways and compare the history.একই দুটো commit দুইভাবে আবার চালান আর history তুলনা করুন।
You’ll learnআপনি শিখবেন
- A merge adds one new commitmerge একটা নতুন commit যোগ করে
- A rebase replays commits as new onesrebase commit-কে নতুন করে চালায়
- Why a rebased log is a straight linerebase করা লগ কেন সরলরেখা
- Why not to rebase shared commitsশেয়ার করা commit কেন rebase নয়
- How bisect finds a commit in few testsbisect কীভাবে কম test-এ commit খোঁজে
What it is
Git has a command for each of these jobs. git rebase reapplies commits on top of another base tip Source 1সোর্স 1. git stash stashes the changes in a dirty working directory away Source 2সোর্স 2. git worktree manages multiple working trees attached to the same repository, so you can check out more than one branch at a time Source 3সোর্স 3. git bisect uses binary search to find the commit that introduced a bug Source 4সোর্স 4. git cherry-pick applies the changes introduced by some existing commits Source 5সোর্স 5.
| Command | A typical use |
|---|---|
git rebase | A cleaner history: the log of a rebased branch looks linear Source 6সোর্স 6 |
git stash | You want to switch branches, but you don't want to commit half-done work Source 7সোর্স 7 |
git worktree | More than one branch checked out at a time Source 3সোর্স 3 |
git bisect | Dozens or hundreds of commits since the code last worked, and you don't know what broke it Source 8সোর্স 8 |
git cherry-pick | Backporting a fix to a maintenance branch for an older release Source 5সোর্স 5 |
git blame | Which revision and author last modified each line of a file Source 11সোর্স 11 |
সহজ English
Git has a command for each of these jobs. git rebase applies commits again, on top of another base tip Source 1সোর্স 1. git stash puts away the changes in a dirty working directory Source 2সোর্স 2. git worktree manages several working trees of the same repository. With it, you can check out more than one branch at a time Source 3সোর্স 3. git bisect uses binary search to find the commit that introduced a bug Source 4সোর্স 4. git cherry-pick applies the changes that some existing commits introduced Source 5সোর্স 5.
| Command | A typical use |
|---|---|
git rebase | A tidier history: a rebased branch looks like one straight line Source 6সোর্স 6 |
git stash | You want to switch branches, but you don't want to commit half-done work Source 7সোর্স 7 |
git worktree | More than one branch checked out at a time Source 3সোর্স 3 |
git bisect | Many commits since the code last worked, and you don't know which one broke it Source 8সোর্স 8 |
git cherry-pick | Copying a fix to the branch of an older release Source 5সোর্স 5 |
git blame | Who last changed each line of a file, and in which commit Source 11সোর্স 11 |
বাংলা ব্যাখ্যা
Git-এ এই প্রতিটি কাজের জন্য একটা করে command আছে। git rebase commit-গুলো অন্য একটা base tip-এর ওপরে আবার বসায় Source 1সোর্স 1। git stash একটা dirty working directory-র পরিবর্তনগুলো সরিয়ে রাখে Source 2সোর্স 2। git worktree একই repository-র একাধিক working tree পরিচালনা করে। এর সাহায্যে আপনি একসাথে একাধিক branch check out করতে পারেন Source 3সোর্স 3। git bisect binary search ব্যবহার করে সেই commit খুঁজে বের করে, যেটা একটা bug ঢুকিয়েছে Source 4সোর্স 4। git cherry-pick কিছু existing commit-এর আনা পরিবর্তনগুলো প্রয়োগ করে Source 5সোর্স 5।
| Command | সাধারণ ব্যবহার |
|---|---|
git rebase | পরিষ্কার history: rebase করা branch-এর log দেখতে সরলরেখার মতো Source 6সোর্স 6 |
git stash | আপনি branch বদলাতে চান, কিন্তু অর্ধেক করা কাজ commit করতে চান না Source 7সোর্স 7 |
git worktree | একসাথে একাধিক branch check out করা Source 3সোর্স 3 |
git bisect | code শেষবার ঠিক চলার পর কয়েক ডজন বা কয়েকশো commit হয়েছে, আর আপনি জানেন না কী ভেঙেছে Source 8সোর্স 8 |
git cherry-pick | পুরোনো release-এর maintenance branch-এ একটা fix backport করা Source 5সোর্স 5 |
git blame | একটা ফাইলের প্রতিটা লাইন শেষবার কোন revision আর কোন author বদলেছেন Source 11সোর্স 11 |
How it works
Branches at levels of stability. Git makes it easy to keep several long-running branches that are always open, for different stages of the development cycle Source 9সোর্স 9. Many Git developers keep only entirely stable code in their master branch, possibly only code that has been or will be released Source 9সোর্স 9. A parallel branch named develop or next is where they work or test stability; when it gets to a stable state, it can be merged into master Source 9সোর্স 9. A topic branch is a short-lived branch for a single feature or related work Source 9সোর্স 9. Topic branches are pulled into develop when they are ready, to make sure that they pass all the tests and don't introduce bugs Source 9সোর্স 9.
master o--------------------o------ only stable code
\ /
develop o---o---o---o---o---o----- tested here, merged up when stable
\ /
topic o---o one feature, merged when readyMerge or rebase. There are two main ways to integrate changes from one branch into another: the merge and the rebase Source 6সোর্স 6. A merge performs a three-way merge between the two latest branch snapshots and their most recent common ancestor, creating a new snapshot and commit Source 6সোর্স 6. A rebase takes all the changes that were committed on one branch and replays them on a different branch Source 6সোর্স 6. There is no difference in the end product, but rebasing makes for a cleaner history Source 6সোর্স 6. When you rebase, you abandon existing commits and create new ones that are similar but different Source 6সোর্স 6:
before: A---B---C main
\
D---E feature
merge: A---B---C-------M main M is a new merge commit
\ /
D-------E
rebase: A---B---C---D'---E' feature D' and E' are new commitsCherry-pick. Given one or more existing commits, git cherry-pick applies the change each one introduces, recording a new commit for each Source 5সোর্স 5. It requires your working tree to be clean Source 5সোর্স 5. With -x, it appends a line that says "(cherry picked from commit …)" to the original commit message Source 5সোর্স 5. This is done only for cherry-picks without conflicts Source 5সোর্স 5.
Stash. Stashing takes the dirty state of your working directory, your modified tracked files and staged changes, and saves it on a stack of unfinished changes Source 7সোর্স 7. You can reapply it at any time, even on a different branch Source 7সোর্স 7. git stash list shows the stashes, git stash apply reapplies one, and git stash pop applies a stash and then immediately drops it from the stack Source 7সোর্স 7.
Worktree. A repository can support multiple working trees, so that you can check out more than one branch at a time Source 3সোর্স 3. Each one that git worktree add creates is a linked worktree; the one that git init or git clone prepared is the main worktree Source 3সোর্স 3.
Bisect. You give git bisect a "bad" commit that is known to contain the bug, and a "good" commit that is known to be before the bug Source 4সোর্স 4. Git picks a commit between the two and asks you whether it is good or bad Source 4সোর্স 4. It keeps narrowing the range until it finds the exact commit that introduced the change Source 4সোর্স 4:
good bad
1 ---- 2 ---- 3 ---- 4 ---- 5 ---- 6 ---- 7 ---- 8
^ test 4: good -> the bug came after 4
^ test 6: bad -> 5 or 6
^ test 5: good -> 6 is the first bad commitWith git bisect run <cmd>, a command does the marking for you Source 4সোর্স 4. Its exit code decides Source 4সোর্স 4:
| Exit code | Meaning for bisect |
|---|---|
| 0 | Good (old) Source 4সোর্স 4 |
| 1 to 127, except 125 | Bad (new) Source 4সোর্স 4 |
| 125 | This commit cannot be tested Source 4সোর্স 4 |
| Any other code | Bisect stops Source 4সোর্স 4 |
সহজ English
Branches at levels of stability. Git makes it easy to keep several long-running branches that are always open, for different stages of the work Source 9সোর্স 9. Many Git developers keep only fully stable code in their master branch, maybe only code that has been or will be released Source 9সোর্স 9. A second branch, called develop or next, is where they work or test that things are stable. When it is stable, it can be merged into master Source 9সোর্স 9. A topic branch is a short-lived branch for one feature or one piece of related work Source 9সোর্স 9. When a topic branch is ready, it goes into develop, to make sure that it passes all the tests and brings no bugs Source 9সোর্স 9.
master o--------------------o------ only stable code
\ /
develop o---o---o---o---o---o----- tested here, merged up when stable
\ /
topic o---o one feature, merged when readyMerge or rebase. Git has two main ways to bring changes from one branch into another: merge and rebase Source 6সোর্স 6. A merge does a three-way merge: it combines the two newest snapshots, using the commit where the branches split, into a new snapshot and a new commit Source 6সোর্স 6. A rebase takes all the changes made on one branch and plays them again on another branch Source 6সোর্স 6. The end result is the same, but the history is tidier Source 6সোর্স 6. When you rebase, you drop the old commits and make new ones that are similar but different Source 6সোর্স 6:
before: A---B---C main
\
D---E feature
merge: A---B---C-------M main M is a new merge commit
\ /
D-------E
rebase: A---B---C---D'---E' feature D' and E' are new commitsCherry-pick. git cherry-pick takes the change of each commit that you give it, and saves it as a new commit Source 5সোর্স 5. Your working tree must be clean first Source 5সোর্স 5. With -x, it adds the line "(cherry picked from commit …)" to the commit message Source 5সোর্স 5. It does this only when the cherry-pick has no conflicts Source 5সোর্স 5.
Stash. A stash takes your unfinished changes, both changed tracked files and staged changes, and puts them on a stack Source 7সোর্স 7. You can put them back at any time, even on another branch Source 7সোর্স 7. git stash list shows the stashes. git stash apply puts one back. git stash pop puts one back and then removes it from the stack Source 7সোর্স 7.
Worktree. One repository can have several working trees, so you can check out more than one branch at a time Source 3সোর্স 3. Each one that git worktree add makes is a linked worktree. The one that git init or git clone made is the main worktree Source 3সোর্স 3.
Bisect. You tell git bisect one "bad" commit that has the bug, and one "good" commit from before the bug Source 4সোর্স 4. Git picks a commit in between and asks you if it is good or bad Source 4সোর্স 4. It keeps cutting the range until it finds the exact commit that brought the change Source 4সোর্স 4:
good bad
1 ---- 2 ---- 3 ---- 4 ---- 5 ---- 6 ---- 7 ---- 8
^ test 4: good -> the bug came after 4
^ test 6: bad -> 5 or 6
^ test 5: good -> 6 is the first bad commitWith git bisect run <cmd>, a command marks each commit for you Source 4সোর্স 4. Its exit code decides Source 4সোর্স 4:
| Exit code | Meaning for bisect |
|---|---|
| 0 | Good (old) Source 4সোর্স 4 |
| 1 to 127, except 125 | Bad (new) Source 4সোর্স 4 |
| 125 | This commit cannot be tested Source 4সোর্স 4 |
| Any other code | Bisect stops Source 4সোর্স 4 |
বাংলা ব্যাখ্যা
stability-র স্তর অনুযায়ী branch। Git-এ সবসময় খোলা থাকা কয়েকটা long-running branch রাখা সহজ, development cycle-এর বিভিন্ন ধাপের জন্য Source 9সোর্স 9। অনেক Git developer তাদের master branch-এ শুধু পুরোপুরি stable code রাখেন, হয়তো শুধু সেই code যা release হয়েছে বা হবে Source 9সোর্স 9। develop বা next নামের একটা সমান্তরাল branch-এ তারা কাজ করেন বা stability test করেন; সেটা stable অবস্থায় পৌঁছালে master-এ merge করা যায় Source 9সোর্স 9। topic branch হলো একটা নির্দিষ্ট feature বা সম্পর্কিত কাজের জন্য স্বল্পস্থায়ী branch Source 9সোর্স 9। topic branch প্রস্তুত হলে develop-এ আনা হয়, যাতে নিশ্চিত হওয়া যায় এটা সব test পাস করে আর কোনো bug আনে না Source 9সোর্স 9।
master o--------------------o------ only stable code
\ /
develop o---o---o---o---o---o----- tested here, merged up when stable
\ /
topic o---o one feature, merged when readyMerge নাকি rebase। এক branch-এর change আরেক branch-এ আনার দুটো প্রধান উপায় আছে: merge আর rebase Source 6সোর্স 6। merge দুই branch-এর সর্বশেষ দুটো snapshot আর তাদের সবচেয়ে কাছের common ancestor নিয়ে three-way merge করে, একটা নতুন snapshot আর commit বানায় Source 6সোর্স 6। rebase এক branch-এ commit হওয়া সব change নিয়ে আরেকটা branch-এর ওপর আবার চালায় Source 6সোর্স 6। শেষ ফলাফলে কোনো পার্থক্য নেই, কিন্তু rebase history-কে পরিষ্কার রাখে Source 6সোর্স 6। rebase করলে আপনি পুরোনো commit বাদ দিয়ে একই রকম কিন্তু আলাদা নতুন commit বানান Source 6সোর্স 6:
before: A---B---C main
\
D---E feature
merge: A---B---C-------M main M is a new merge commit
\ /
D-------E
rebase: A---B---C---D'---E' feature D' and E' are new commitsCherry-pick। এক বা একাধিক existing commit দিলে git cherry-pick প্রতিটার আনা change প্রয়োগ করে, প্রতিটার জন্য একটা নতুন commit রেকর্ড করে Source 5সোর্স 5। এর জন্য আপনার working tree পরিষ্কার থাকতে হয় Source 5সোর্স 5। -x দিলে এটা মূল commit message-এর শেষে "(cherry picked from commit …)" লাইনটা যোগ করে Source 5সোর্স 5। এটা শুধু conflict ছাড়া cherry-pick-এর বেলায় হয় Source 5সোর্স 5।
Stash। stash আপনার working directory-র অগোছালো অবস্থা, মানে বদলানো tracked ফাইল আর staged change, নিয়ে অসমাপ্ত change-এর একটা stack-এ রাখে Source 7সোর্স 7। যেকোনো সময় আবার প্রয়োগ করা যায়, এমনকি অন্য branch-এও Source 7সোর্স 7। git stash list stash-গুলো দেখায়, git stash apply একটা আবার প্রয়োগ করে, আর git stash pop প্রয়োগ করে সাথে সাথে stack থেকে মুছে দেয় Source 7সোর্স 7।
Worktree। একটা repository একাধিক working tree রাখতে পারে, যাতে একসাথে একাধিক branch check out করা যায় Source 3সোর্স 3। git worktree add যেটা বানায় সেটা linked worktree; git init বা git clone যেটা বানিয়েছিল সেটা main worktree Source 3সোর্স 3।
Bisect। আপনি git bisect-কে একটা "bad" commit দেন, যাতে bug আছে বলে জানা, আর একটা "good" commit দেন, যেটা bug-এর আগের বলে জানা Source 4সোর্স 4। Git দুটোর মাঝের একটা commit বেছে নিয়ে জিজ্ঞেস করে সেটা good নাকি bad Source 4সোর্স 4। যতক্ষণ না ঠিক কোন commit change-টা এনেছে তা পায়, ততক্ষণ এটা পরিসর ছোট করতে থাকে Source 4সোর্স 4:
good bad
1 ---- 2 ---- 3 ---- 4 ---- 5 ---- 6 ---- 7 ---- 8
^ test 4: good -> the bug came after 4
^ test 6: bad -> 5 or 6
^ test 5: good -> 6 is the first bad commitgit bisect run <cmd> দিলে একটা command আপনার হয়ে প্রতিটা commit চিহ্নিত করে Source 4সোর্স 4। এর exit code সিদ্ধান্ত নেয় Source 4সোর্স 4:
| Exit code | bisect-এর কাছে মানে |
|---|---|
| 0 | Good (old) Source 4সোর্স 4 |
| 1 থেকে 127, 125 বাদে | Bad (new) Source 4সোর্স 4 |
| 125 | এই commit test করা যায় না Source 4সোর্স 4 |
| অন্য যেকোনো code | bisect থেমে যায় Source 4সোর্স 4 |
Try it
This practice run needs only Git and a bash shell. You make a repository with a known bug, find the bug's commit twice, and then use a stash and a worktree.
1. Make a practice repository. This script is the tutorial's own. It makes eight commits. Commit 6 changes the total from 100 to 110: that is the "bug". It uses only basic commands: git init makes a repository with a .git subdirectory Source 13সোর্স 13, git add stages files, git commit -m records a commit with an inline message Source 14সোর্স 14, and git log --oneline prints each commit on a single line Source 12সোর্স 12.
mkdir bisect-practice && cd bisect-practice
git init
for i in 1 2 3 4 5 6 7 8; do
if [ "$i" -lt 6 ]; then echo "total=100" > price.txt; else echo "total=110" > price.txt; fi
echo "change $i" >> notes.txt
git add price.txt notes.txt
git commit -m "Change $i"
done
git log --oneline2. Find the bad commit by hand. Start a session, mark the current commit as bad, and mark the oldest one as good Source 4সোর্স 4. Git then checks out a commit in between Source 4সোর্স 4. Read price.txt: if it says total=100, run git bisect good, otherwise git bisect bad. Repeat until Git prints the first bad commit Source 4সোর্স 4. Then git bisect reset returns you to the commit that you had before Source 4সোর্স 4.
git bisect start
git bisect bad
git bisect good HEAD~7
cat price.txt
git bisect good # or: git bisect bad
git bisect reset3. Let a command do it. You can list the known bad commit first and the known good commit second in git bisect start Source 8সোর্স 8. git grep -q exits with status 0 when there is a match, and with a non-zero status when there is not Source 10সোর্স 10. So git bisect run marks a commit good when price.txt says total=100, and bad when it does not Source 4সোর্স 4:
git bisect start HEAD HEAD~7
git bisect run git grep -q "total=100" -- price.txt
git bisect resetAt the end, Git prints a description of the first bad commit Source 4সোর্স 4. When this tutorial ran the script, the output ended like this; your hash will differ:
7b6cfbb400a088f4d6d942ce77645ad8416b6657 is the first bad commit
commit 7b6cfbb400a088f4d6d942ce77645ad8416b6657
...
Change 64. Put work away with a stash. git stash -u also takes untracked files, such as a new test file Source 7সোর্স 7. A stash reverts the working directory to match the HEAD commit, so git status shows a clean tree Source 2সোর্স 2. git stash pop brings the work back and drops the stash Source 7সোর্স 7.
echo "draft test" > login.spec.txt
echo "work in progress" >> notes.txt
git stash -u
git status
git stash list
git stash pop5. Check out a second branch with a worktree. git worktree add ../hotfix creates a new branch hotfix and checks it out at the path ../hotfix Source 3সোর্স 3. git worktree list shows the main worktree first, then the linked ones Source 3সোর্স 3. When you are done, remove it with git worktree remove Source 3সোর্স 3.
git worktree add ../hotfix
git worktree list
git worktree remove ../hotfixসহজ English
You need only Git and a bash shell. You make a repository with a known bug, find the bug's commit two ways, and then try a stash and a worktree.
1. Make a practice repository. This script is the tutorial's own. It makes eight commits. Commit 6 changes the total from 100 to 110: that is the "bug". It uses only basic commands: git init makes a repository with a .git subdirectory Source 13সোর্স 13, git add stages files, git commit -m records a commit with an inline message Source 14সোর্স 14, and git log --oneline prints each commit on a single line Source 12সোর্স 12.
mkdir bisect-practice && cd bisect-practice
git init
for i in 1 2 3 4 5 6 7 8; do
if [ "$i" -lt 6 ]; then echo "total=100" > price.txt; else echo "total=110" > price.txt; fi
echo "change $i" >> notes.txt
git add price.txt notes.txt
git commit -m "Change $i"
done
git log --oneline2. Find the bad commit by hand. Start a session. Mark the current commit as bad, and the oldest one as good Source 4সোর্স 4. Git then opens a commit in between Source 4সোর্স 4. Read price.txt. If it says total=100, run git bisect good. If not, run git bisect bad. Do this until Git prints the first bad commit Source 4সোর্স 4. Then git bisect reset takes you back to where you were Source 4সোর্স 4.
git bisect start
git bisect bad
git bisect good HEAD~7
cat price.txt
git bisect good # or: git bisect bad
git bisect reset3. Let a command do it. In git bisect start, you can give the bad commit first and the good commit second Source 8সোর্স 8. git grep -q ends with status 0 when it finds the text, and with another status when it does not Source 10সোর্স 10. So git bisect run marks a commit good when price.txt says total=100, and bad when it does not Source 4সোর্স 4:
git bisect start HEAD HEAD~7
git bisect run git grep -q "total=100" -- price.txt
git bisect resetAt the end, Git prints a description of the first bad commit Source 4সোর্স 4. When this tutorial ran the script, the output ended like this. Your hash will be different:
7b6cfbb400a088f4d6d942ce77645ad8416b6657 is the first bad commit
commit 7b6cfbb400a088f4d6d942ce77645ad8416b6657
...
Change 64. Put work away with a stash. git stash -u also takes untracked files, such as a new test file Source 7সোর্স 7. A stash puts the working directory back to the HEAD commit, so git status shows a clean tree Source 2সোর্স 2. git stash pop brings the work back and removes the stash Source 7সোর্স 7.
echo "draft test" > login.spec.txt
echo "work in progress" >> notes.txt
git stash -u
git status
git stash list
git stash pop5. Open a second branch with a worktree. git worktree add ../hotfix makes a new branch hotfix and opens it in the folder ../hotfix Source 3সোর্স 3. git worktree list shows the main worktree first, then the linked ones Source 3সোর্স 3. When you are done, remove it with git worktree remove Source 3সোর্স 3.
git worktree add ../hotfix
git worktree list
git worktree remove ../hotfixবাংলা ব্যাখ্যা
এই practice-এ শুধু Git আর একটা bash shell লাগে। আপনি জানা bug-সহ একটা repository বানাবেন, bug-এর commit দুইভাবে খুঁজবেন, তারপর একটা stash আর একটা worktree ব্যবহার করবেন।
১. একটা practice repository বানান। এই script টিউটোরিয়ালের নিজের। এটা আটটা commit বানায়। commit 6 total 100 থেকে 110 করে দেয়: এটাই "bug"। এতে শুধু মৌলিক command আছে: git init একটা .git subdirectory-সহ repository বানায় Source 13সোর্স 13, git add ফাইল stage করে, git commit -m message-সহ একটা commit রেকর্ড করে Source 14সোর্স 14, আর git log --oneline প্রতিটা commit এক লাইনে দেখায় Source 12সোর্স 12।
mkdir bisect-practice && cd bisect-practice
git init
for i in 1 2 3 4 5 6 7 8; do
if [ "$i" -lt 6 ]; then echo "total=100" > price.txt; else echo "total=110" > price.txt; fi
echo "change $i" >> notes.txt
git add price.txt notes.txt
git commit -m "Change $i"
done
git log --oneline২. হাতে bad commit খুঁজুন। একটা session শুরু করুন, বর্তমান commit-কে bad আর সবচেয়ে পুরোনোটাকে good চিহ্নিত করুন Source 4সোর্স 4। Git তখন মাঝের একটা commit check out করে Source 4সোর্স 4। price.txt পড়ুন: total=100 লেখা থাকলে git bisect good চালান, না হলে git bisect bad। Git first bad commit না দেখানো পর্যন্ত এটা করতে থাকুন Source 4সোর্স 4। তারপর git bisect reset আপনাকে আগের commit-এ ফিরিয়ে নেয় Source 4সোর্স 4।
git bisect start
git bisect bad
git bisect good HEAD~7
cat price.txt
git bisect good # or: git bisect bad
git bisect reset৩. একটা command-কে দিয়ে করান। git bisect start-এ আগে জানা bad commit আর পরে জানা good commit দিতে পারেন Source 8সোর্স 8। match থাকলে git grep -q status 0 দিয়ে শেষ হয়, আর না থাকলে non-zero status দিয়ে Source 10সোর্স 10। তাই price.txt-এ total=100 থাকলে git bisect run commit-কে good চিহ্নিত করে, না থাকলে bad Source 4সোর্স 4:
git bisect start HEAD HEAD~7
git bisect run git grep -q "total=100" -- price.txt
git bisect resetশেষে Git first bad commit-এর একটা বর্ণনা print করে Source 4সোর্স 4। এই টিউটোরিয়াল script-টা চালানোর সময় output-এর শেষটা এমন ছিল; আপনার hash আলাদা হবে:
7b6cfbb400a088f4d6d942ce77645ad8416b6657 is the first bad commit
commit 7b6cfbb400a088f4d6d942ce77645ad8416b6657
...
Change 6৪. stash দিয়ে কাজ সরিয়ে রাখুন। git stash -u untracked ফাইলও নেয়, যেমন একটা নতুন test ফাইল Source 7সোর্স 7। stash working directory-কে HEAD commit-এর মতো করে দেয়, তাই git status একটা পরিষ্কার tree দেখায় Source 2সোর্স 2। git stash pop কাজটা ফিরিয়ে আনে আর stash মুছে দেয় Source 7সোর্স 7।
echo "draft test" > login.spec.txt
echo "work in progress" >> notes.txt
git stash -u
git status
git stash list
git stash pop৫. worktree দিয়ে দ্বিতীয় branch check out করুন। git worktree add ../hotfix hotfix নামে একটা নতুন branch বানিয়ে ../hotfix path-এ check out করে Source 3সোর্স 3। git worktree list আগে main worktree, তারপর linked-গুলো দেখায় Source 3সোর্স 3। কাজ শেষ হলে git worktree remove দিয়ে সরিয়ে দিন Source 3সোর্স 3।
git worktree add ../hotfix
git worktree list
git worktree remove ../hotfixHow a tester uses it
Find the commit that broke a test. When you don't know what is breaking, and there have been dozens or hundreds of commits since the code last worked, use git bisect Source 8সোর্স 8. If you have a script that exits 0 when the project is good and non-0 when it is bad, you can fully automate it Source 8সোর্স 8. You can also run whatever you have that runs automated tests for you Source 8সোর্স 8.
Find the change to one line. If a method in your code is buggy, git blame can show which commit introduced that line Source 8সোর্স 8. It annotates each line of a file with information from the revision that last modified it Source 11সোর্স 11.
Trace a fix to a release branch. A cherry-picked fix is a new commit on the release branch Source 5সোর্স 5. When a fix moves between two publicly visible branches, such as a backport to a maintenance branch, the -x line can be useful Source 5সোর্স 5. It names the commit that the change came from Source 5সোর্স 5.
Test two branches side by side. With linked worktrees, you can check out more than one branch at a time Source 3সোর্স 3. To work on an existing branch in a new worktree, use git worktree add <path> <branch> Source 3সোর্স 3.
Pause your own work. When your work is in a messy state and you want to switch branches for a bit to work on something else, stash your half-done changes instead of committing them Source 7সোর্স 7. You can reapply them later, even on a different branch Source 7সোর্স 7.
Know which commits you tested. After a rebase, the branch is made of new commits Source 6সোর্স 6.
সহজ English
Find the commit that broke a test. When you don't know what broke, and many commits came after the code last worked, use git bisect Source 8সোর্স 8. If a script ends with 0 when things are good and with another number when they are bad, bisect can run on its own Source 8সোর্স 8. You can also run whatever runs your automated tests Source 8সোর্স 8.
Find the change to one line. If one method in your code is buggy, git blame can show which commit added that line Source 8সোর্স 8. It marks each line of a file with the commit that last changed it Source 11সোর্স 11.
Follow a fix to a release branch. A cherry-picked fix is a new commit on the release branch Source 5সোর্স 5. When a fix moves between two public branches, for example to the branch of an older release, the -x line can help Source 5সোর্স 5. It names the commit that the change came from Source 5সোর্স 5.
Test two branches side by side. With linked worktrees, you can check out more than one branch at a time Source 3সোর্স 3. To open an existing branch in a new worktree, use git worktree add <path> <branch> Source 3সোর্স 3.
Pause your own work. When your work is in a messy state and you want to switch branches for a bit to do something else, stash your half-done changes instead of committing them Source 7সোর্স 7. You can bring them back later, even on another branch Source 7সোর্স 7.
Know which commits you tested. After a rebase, the branch is made of new commits Source 6সোর্স 6.
বাংলা ব্যাখ্যা
যে commit একটা test ভেঙেছে, সেটা খুঁজুন। কী ভাঙছে জানেন না, আর code শেষবার ঠিক চলার পর কয়েক ডজন বা কয়েকশো commit হয়েছে, এমন হলে git bisect ব্যবহার করুন Source 8সোর্স 8। আপনার কাছে এমন script থাকলে, যেটা project ঠিক থাকলে 0 আর খারাপ হলে non-0 দিয়ে শেষ হয়, তাহলে পুরো কাজটা automate করা যায় Source 8সোর্স 8। আপনার automated test চালানোর যেকোনো command-ও চালাতে পারেন Source 8সোর্স 8।
একটা লাইনের change খুঁজুন। code-এর কোনো method-এ bug থাকলে git blame দেখাতে পারে কোন commit সেই লাইনটা এনেছে Source 8সোর্স 8। এটা একটা ফাইলের প্রতিটা লাইনের পাশে সেই revision-এর তথ্য দেখায়, যেটা লাইনটা শেষবার বদলেছে Source 11সোর্স 11।
release branch-এ একটা fix অনুসরণ করুন। cherry-pick করা fix release branch-এ একটা নতুন commit Source 5সোর্স 5। দুটো public branch-এর মধ্যে fix গেলে, যেমন পুরোনো release-এর maintenance branch-এ backport, -x লাইনটা কাজে লাগতে পারে Source 5সোর্স 5। এটা বলে change-টা কোন commit থেকে এসেছে Source 5সোর্স 5।
দুটো branch পাশাপাশি test করুন। linked worktree দিয়ে একসাথে একাধিক branch check out করা যায় Source 3সোর্স 3। আগে থেকে থাকা একটা branch নতুন worktree-তে নিতে git worktree add <path> <branch> ব্যবহার করুন Source 3সোর্স 3।
নিজের কাজ থামিয়ে রাখুন। কাজ এলোমেলো অবস্থায় আছে, আর কিছুক্ষণের জন্য branch বদলে অন্য কাজ করতে চান: তখন অর্ধেক করা change commit না করে stash করুন Source 7সোর্স 7। পরে সেগুলো আবার প্রয়োগ করতে পারবেন, এমনকি অন্য branch-এও Source 7সোর্স 7।
কোন commit test করেছেন, তা জানুন। rebase-এর পরে branch নতুন commit দিয়ে তৈরি হয় Source 6সোর্স 6।
Common mistakes
- Rebasing shared commits. Do not rebase commits that exist outside your repository and that people may have based work on Source 6সোর্স 6. Rebase local changes before you push, but never rebase anything that you have pushed somewhere Source 6সোর্স 6.
- Forgetting
git bisect reset. After a bisect session, it cleans up the bisection state and returns you to the originalHEADSource 4সোর্স 4. - A bisect script with the wrong exit code. Any exit code other than 0 to 127 aborts the bisect Source 4সোর্স 4. A program that ends with
exit(-1)leaves the code 255 Source 4সোর্স 4. For a commit that cannot be tested, exit with 125 Source 4সোর্স 4. - Skipping the wrong commit. If you skip a commit next to the one that you are looking for, Git cannot tell exactly which of those commits was the first bad one Source 4সোর্স 4.
- Losing new files in a stash. By default,
git stashstashes only modified and staged tracked files Source 7সোর্স 7. Add-u(--include-untracked) to include untracked files Source 7সোর্স 7. - Deleting a worktree folder by hand. Use
git worktree removeSource 3সোর্স 3. If the folder is already gone,git worktree pruneremoves the worktree information that is left Source 3সোর্স 3. - Cherry-picking into a dirty tree.
git cherry-pickrequires a clean working tree Source 5সোর্স 5.
সহজ English
- Rebasing shared commits. Do not rebase commits that are outside your repository, which other people may have built on Source 6সোর্স 6. Rebase your own changes before you push, but never rebase anything that you have pushed Source 6সোর্স 6.
- Forgetting
git bisect reset. After a bisect, it cleans up and takes you back to where you started Source 4সোর্স 4. - A bisect script with the wrong exit code. Any exit code outside 0 to 127 stops the bisect Source 4সোর্স 4. A program that ends with
exit(-1)gives the code 255 Source 4সোর্স 4. If a commit cannot be tested, end with 125 Source 4সোর্স 4. - Skipping the wrong commit. If you skip a commit next to the one that you are looking for, Git cannot tell exactly which of them was the first bad one Source 4সোর্স 4.
- Losing new files in a stash. By default,
git stashtakes only changed and staged files that Git tracks Source 7সোর্স 7. Add-u(--include-untracked) to take untracked files too Source 7সোর্স 7. - Deleting a worktree folder by hand. Use
git worktree removeSource 3সোর্স 3. If the folder is already gone,git worktree prunecleans up what is left Source 3সোর্স 3. - Cherry-picking with uncommitted changes.
git cherry-pickneeds a clean working tree Source 5সোর্স 5.
বাংলা ব্যাখ্যা
- shared commit rebase করা। যেসব commit আপনার repository-র বাইরে আছে আর অন্যরা যার ওপর কাজ করে থাকতে পারেন, সেগুলো rebase করবেন না Source 6সোর্স 6। push-এর আগে local change rebase করুন, কিন্তু যা কোথাও push করেছেন তা কখনো rebase করবেন না Source 6সোর্স 6।
git bisect resetভুলে যাওয়া। bisect session-এর পরে এটা bisection-এর state পরিষ্কার করে আর আপনাকে আগেরHEAD-এ ফিরিয়ে দেয় Source 4সোর্স 4।- ভুল exit code-ওয়ালা bisect script। 0 থেকে 127-এর বাইরের যেকোনো exit code bisect বাতিল করে দেয় Source 4সোর্স 4।
exit(-1)দিয়ে শেষ হওয়া program code 255 রেখে যায় Source 4সোর্স 4। যে commit test করা যায় না, তার জন্য 125 দিয়ে শেষ করুন Source 4সোর্স 4। - ভুল commit skip করা। আপনি যেটা খুঁজছেন তার পাশের commit skip করলে Git ঠিক বলতে পারে না কোনটা first bad commit Source 4সোর্স 4।
- stash-এ নতুন ফাইল হারানো। default-এ
git stashশুধু বদলানো আর staged tracked ফাইল stash করে Source 7সোর্স 7। untracked ফাইলও নিতে-u(--include-untracked) দিন Source 7সোর্স 7। - হাতে worktree ফোল্ডার মুছে ফেলা।
git worktree removeব্যবহার করুন Source 3সোর্স 3। ফোল্ডার আগেই মুছে গেলেgit worktree pruneবাকি থাকা worktree তথ্য সরিয়ে দেয় Source 3সোর্স 3। - অপরিষ্কার tree-তে cherry-pick করা।
git cherry-pick-এর জন্য working tree পরিষ্কার থাকতে হয় Source 5সোর্স 5।
What a tester can check
Tutorial advice
This list is the tutorial's own advice for a tester who uses these commands.
- Before you bisect with a test, run it a few times on the bad commit and on the good one. A flaky test marks commits wrongly.
- For
git bisect run, use a command that runs only the failing test. - Put the hash and the title of the first bad commit in the bug report.
- Ask whether fixes on release branches are cherry-picked with
-x, so that you can trace them. - After a branch is rebased, run its tests again, because its commits are new.
- Ask which branch holds only stable code and which branch is for testing.
- Keep half-done test work in a stash or a worktree, not in a half-done commit on a shared branch.
সহজ English
Tutorial advice
This list is the tutorial's own advice for a tester who uses these commands.
- Before you bisect with a test, run it a few times on the bad commit and on the good one. A flaky test marks commits wrongly.
- For
git bisect run, use a command that runs only the failing test. - Put the hash and the title of the first bad commit in the bug report.
- Ask if fixes on release branches are cherry-picked with
-x, so that you can follow them. - After a branch is rebased, run its tests again, because its commits are new.
- Ask which branch has only stable code, and which branch is for testing.
- Keep half-done test work in a stash or a worktree, not in a half-done commit on a shared branch.
বাংলা ব্যাখ্যা
Tutorial advice
এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, এই command-গুলো ব্যবহার করা একজন tester-এর জন্য।
- একটা test দিয়ে bisect করার আগে সেটা bad আর good commit-এ কয়েকবার চালান। flaky test commit-কে ভুল চিহ্নিত করে।
git bisect run-এ এমন command দিন, যেটা শুধু ফেল করা test-টা চালায়।- first bad commit-এর hash আর title bug report-এ লিখুন।
- জিজ্ঞেস করুন release branch-এর fix
-xদিয়ে cherry-pick করা হয় কি না, যাতে সেগুলো খুঁজে পাওয়া যায়। - একটা branch rebase হলে তার test আবার চালান, কারণ তার commit-গুলো নতুন।
- জিজ্ঞেস করুন কোন branch-এ শুধু stable code থাকে, আর কোনটা test-এর জন্য।
- অর্ধেক করা test-এর কাজ stash বা worktree-তে রাখুন, shared branch-এ অর্ধেক করা commit হিসেবে নয়।
Key words
| Term | Meaning |
|---|---|
| Long-running branch | A branch that stays open, such as master for stable code or develop for testing stability |
| Topic branch | A short-lived branch for a single feature or related work |
| Rebase | Replaying the changes of one branch on another branch, as new commits |
| Cherry-pick | Applying the change of an existing commit as a new commit |
-x | The cherry-pick option that adds "(cherry picked from commit …)" to the message of a cherry-pick without conflicts |
| Stash | A stack of unfinished changes that you can reapply later |
| Linked worktree | An extra working tree made by git worktree add |
| Main worktree | The working tree that git init or git clone prepared |
| Bisect | A binary search for the commit that introduced a change |
| Good (old) / bad (new) | A good commit is known to be before the bug, and a bad one contains it; for git bisect run, exit code 0 means good |
git bisect run | Bisect with a command whose exit code marks each commit |
| Exit code 125 | Tells bisect that a commit cannot be tested |
git blame | Shows the revision and author that last modified each line |