git update local branch from remote code example

Example 1: how to update remote branches list git

git remote update origin --prune

Example 2: git replace local branch with remote

git fetch
git reset --hard origin/{{branch}}
# replace {{branch}} with name

Example 3: git replace local branch with remote

git reset --hard origin/master

Example 4: git fetch remote branch

git checkout --track origin/branch_name

Example 5: git sync branches

git fetch origin
git reset --hard origin/master
git clean -f -d

#If you want to retain the changes as unstaged files, use --soft instead of --hard.
#WARNING: All your untracked files will be gone when you do git clean -f -d.

Example 6: push local branch changes to remote branch

git push -u origin localBranch:remoteBranchToBeCreated