- First fork or clone your remote git project
- Delete existing history and commits by deleting
.git
folder - Add remote git project as upstream
- Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.
git fetch upstream
- Check out your local master branch.
git checkout master
- Merge the changes from upstream/master into your local master branch. This brings your master branch into sync with the upstream repository, without losing your local changes.
git merge --allow-unrelated-histories --squash upstream/master
not work for gitlap