How to sync branches in git?

Member

by lizzie , in category: Third Party Scripts , 3 months ago

How to sync branches in git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by lindsey.homenick , 3 months ago

@lizzie 

To sync branches in git, you can do the following:

  1. To update a branch with the changes from its remote branch:
1
2
git checkout <branch-name>
git pull origin <branch-name>


  1. To merge changes from one branch to another:
1
2
git checkout <branch-1>
git merge <branch-2>


  1. To rebase changes from one branch to another:
1
2
git checkout <branch-1>
git rebase <branch-2>


  1. To push changes from a local branch to a remote branch:
1
git push origin <branch-name>


  1. To fetch all remote branches and update the local repository:
1
git fetch


  1. To delete a local branch:
1
git branch -d <branch-name>


  1. To delete a remote branch:
1
git push origin --delete <branch-name>


By following these commands, you can synchronize branches in git and keep your local and remote repositories up to date.