Andrunevchyn

Andrunevchyn


December 2020
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories


GitLab and GitHub synchronization

Andriy AndrunevchynAndriy Andrunevchyn

We use GitLab as our version control system. Due to specific customer requirements periodically we should push latest changes to GitHub account. So if you should do the same just follow this instruction

  1. Assign alias for remote GitHub account
git remote add MyRemoteGitAccountAlias https://yourLogin@github.com/yourLogin/yourRepoName.git
  1. Pull latest changes
git pull
  1. Push all changes to remote GitHub account
git push --mirror MyRemoteGitAccountAlias

Pay attention you will push all branches and tags so perhaps you would like to remove all local branches except required one. You could do this with the following command.

Linux

Remove all except trunk

git branch | grep -v "trunk" | xargs git branch -D

Remove all except dev and trunk

git branch | grep -v "trunk\|dev" | xargs git branch -D

Remove all merged except trunk

git branch --merged master | grep -v "trunk" | xargs git branch -D

Windows (run PowerShell)

git branch | Select-String -NotMatch -Pattern "trunk" | %{ git branch -D $_.ToString().Trim() }

P.S.

If you would like just remove outdated branches which were already removed on remote but still are present locally then you could execute

git fetch --prune

andriy@andrunevchyn.com

Comments 0
There are currently no comments.