Imagine you wrote a program : it's made of several files, plenty of commits, and one of them introduced a bug (or anything unwanted). git bisect can help finding which commit caused that To do so, you'll have to tell Git whether commits are bad
(the bug is present in this commit) or good
(bug not present in this commit).
bad
commit :
good
commit :detached head)
good
or bad
. To figure this out, you'll have to execute your code, run unit tests, ..., then let Git know :
Flag | Usage |
---|---|
--reverse commitId..commitId |
|
Flag | Usage |
---|---|
none :
|
it depends :
|
-a | list all branches : local + remote
git branch -a = git branch + git branch -r
|
-D branch | Delete branch branch irrespective of its merged status |
-d branch | delete the fully merged branch branch To delete a remote branch : git push -d remote branch
|
-f --force | git branch -f branch startPoint forces Git to reset branch to startPoint, even if branch exists already. Otherwise, Without -f, git branch refuses to change an existing branch. |
-m oldName newName | Rename (move) branch oldName into newName : git branch -m oldName newName |
-r --remotes | list the remote-tracking branches |
-u remoteBranch --set-upstream-to=remoteBranch |
Set up localBranch's tracking information so remoteBranch is considered localBranch's upstream branch. If no localBranch is specified, then it defaults to the current branch.
git branch -u origin/branch
|
--unset-upstream branch | Remove the upstream information for branch. Defaults to the current branch if no branch is specified. |
-v -vv --verbose | when in list mode (toggled by -a and others), list not only the branch name (the default), but also :
|
git branch newBranch
This new branch is not selected by default. To do so : git checkout newBranch
* 1d791e1 (HEAD -> master) Added 'D' * 7d07f0e Added 'C' * b5e0a67 Added 'B' this will become the "common ancestor" to both branches * 7177ae6 Added 'A' * b728cee initial version
Switched to branch 'newBranch'
* bad4a24 (HEAD -> newBranch) Added 'H' * 680aaa3 Added 'G' * 52ded27 Added 'F' * 5cf765a Added 'E' * b5e0a67 Added 'B' actually the ancestor of the 2nd round of commits (as expected) * 7177ae6 Added 'A' * b728cee initial version
Switched to branch 'master' * 1d791e1 (HEAD -> master) Added 'D' * 7d07f0e Added 'C' * b5e0a67 Added 'B' still there, with the same children * 7177ae6 Added 'A' * b728cee initial version
currentGitBranch=$(git branch 2>/dev/null | awk '/^\*/ {print $2}') echo "$currentGitBranch"
A---B---C---D---E master \ F---G---H featurehow can I find C ?
Use git merge-base.