Branching & Merging Flashcards
(25 cards)
How do you create a new branch?
git branch branch_name
How do you switch to an existing branch?
git checkout branch_name
How do you merge changes from one branch into another?
git merge source_branch
How do you delete a local branch?
git branch -d branch_name
How do you list all branches in the repository?
git branch –all
How do you create a new branch and switch to it in one command?
git checkout -b branch_name
How do you rename a branch?
git branch -m old_name new_name
How do you show the commit history of a specific branch?
git log branch_name
How do you merge a branch and create a merge commit even if the merge could be a fast-forward?
git merge –no-ff branch_name
How do you abort a merge in case of conflicts?
git merge –abort
How do you list branches that contain a specific commit?
git branch –contains commit_hash
How do you compare the differences between two branches?
git diff branch1 branch2
How do you show the commit history of a branch
excluding merges?
How do you rebase a branch onto another branch?
git rebase target_branch
How do you abort a rebase operation?
git rebase –abort
How do you continue a rebase operation after resolving conflicts?
git rebase –continue
How do you show the common ancestor of two branches?
git merge-base branch1 branch2
How do you push a new branch to a remote repository?
git push -u origin branch_name
How do you delete a remote branch?
git push origin –delete branch_name
How do you list all branches that have been merged into the current branch?
git branch –merged
How do you list all branches that have not been merged into the current branch?
git branch –no-merged
How do you create a branch at a specific commit?
git branch branch_name commit_hash
How do you set the upstream branch for the current branch?
git branch –set-upstream-to=origin/branch_name
How do you cherry-pick a commit from another branch into the current branch?
git cherry-pick commit_hash