Sync¶
push¶
push local branch to remote branch with the same name
fetch¶
fetch remote branch
merge¶
merge remote branch to current branch
pull¶
fetch remote branch and merge to local branch
remove a local repo¶
clone repo to local folder¶
clone local to azure repo¶
upstream to master (sync a fork)¶
git checkout master #check out fork's local default branch
git fetch upstream #fetch upstream branches and commits
git merge upstream/master #merge upstream/master into local current branch
git push origin master #push local changes to origin/master
upstream to local branch (rebase)¶
git checkout my-branch
git stash
git fetch upstream
git rebase upstream/master #rebase my-branch from the upstream’s master branch
git stash
# if the local branch is already in a pr
git push --force-with-lease origin my-branch # don't overwrite remote changes we don't have locally
master to local branch¶
git checkout my-branch
git fetch origin #git pull origin master, OK but better use
git merge origin/master
remote azure branch to local master¶
git checkout <local-branch>
git fetch azure
git merge <repo>/<remote-branch> #merge to local checked-out branch
# example
git checkout main
git fetch origin
git merge origin/main
remote azure branch to local new branch¶
local branch to remote azure branch¶
# first time add upstream
git push -u azure local-branch
# git push <repo> <local-branch>:<remote-branch>
git push azure local-branch:remote-branch
merge upstream repo into fork¶
#check out branch to merge to
git checkout my-branch
#pull the desired branch from the upstream repo
git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git branch-name
#commit the merge
#push merge to GitHub repo
git push origin branch-name
cherry-pick¶
cherry-pick from github repo to azure devops repo