My source code is currently hosted on VisualStudio.com (VSTS) in a Git repository. The client has asked that after every sprint the code should be updated in his owned repository in bitbucket without the long history that I may have on VSTS.
The firs time I did this in a very crude way. I retrieved all code from the dev branch to a temp folder, deleted Git folder and then performed git init and added all the files to client's bit bucket repository.
Now I already have source in both locations. Is there an easier way to achieve this? Overwriting the files is not making them marked as changed but as deleted and added in bitbucket.
so I can think of these steps. - Get the latest version from the branch - Squash the history locally ??? - Set the remote to client's repo??? - perform a commit ???
I had to write these steps because I think people are thinking it's the first commit I'm making in his repo. No, I already had the first commit. this question is about subsequent commits.
You can
git merge --squash
, which fold all your changes into a single commit. With this method git does a regular merge, but does not take your branch as a parent for the new commit. The squashed commits will be placed into the commit message, so you might want to edit this too. With this approach you don't loose your history, while you can fulfill your customers requirements.As a side note, I never worked with squash commits, so I can't tell if there are side effects like recurring merge conflicts since git does not know about the same ancestors when you do changes on an already merged branch.
This is an example how the history would look like: