Branching & Merging Flashcards
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