Git collaboration workshop
git clone <URL>
: downloads the repository from the web to our computer- Make sure you don't nest this command in another repository
- just like
git init
do this only once per repository
-
git branch <branch_name>
: create a new branch -
git switch <branch_name>
: move to a branchgit checkout <branch_name>
: old way of moving to branch
-
git switch -c <branch_name>
: create and move in 1 commandgit checkout -b <branch_name>
-
git stash
: temp saves current state as a commit so you cancheckout
orswitch
git stash apply
to apply
git push origin <branch_name>
: pushes branch to the remote- this is where you will create PR (online)
- you merge the PR (and also the branch) by accepting and merging the PR
- don't forget ti clean up your branches
git fetch --prune
: clean up the references in yourgit log --oneline --graph --decorate --all
git branch -d <branch_name>
: delete branch on your local machine- it will tell you to move to another branch (e.g.
master
) first
- it will tell you to move to another branch (e.g.
git rebase <branch>
: ifbranch
ismaster
replay the current branch off master- will auto merge if possible
- potentially deal with conflicts