# MIGRATING LOCAL TO ANOTHER REPO
## Add new remote repository named production
```git
git remote add production git@url:project.git
```
## Squash all commits since the creation of the branch
```git
git checkout myBranch # switch to mBranch
git log master..myBranch # shows commits made since the creation of the myBranch branch out of master
git rebase -i master # interactive rebase
```
### When editor opens:
- :%s/pick/s/g # vim command to replace all pick words with s (squash) from the file
- only **first** commit should be left as pick (p)
## Push changes into production remote repo
```git
git push production feature1:feature1-production
git checkout feature1-production
```
## Remove commits from the previous parent branch
```git
git rebase -i origin/master -Xtheirs # accept feature branch changes on conflicts
```
### When editor opens:
- :%s/pick/d/g # vim command to replace all pick words with d (delete)from the file
to delete all previous commits
- only **last** commit should be left as pick (p)
## If some conflicts arise, resolve them and execute following commands:
```git
git add . # add all files to the stage
git commit # commit files
git rebase --continue # continue with rebasing
```
```git
git push -f # force push changes at the end
```