0

I had to change my laptop hdd to sdd, I have backup of my local files. Now I want to synch my local files and existing bitbucket repo without losing my changes in my local folder.

What is the correct way to do it ?

Thanks

edit : tried to solve same way as the suggested question before suggestion, I got errors fatal: refusing to merge unrelated histories

I had to do following steps first git pull origin master --allow-unrelated-histories

then git merge origin origin/master after commit and git push origin master

ytsejam
  • 3,291
  • 7
  • 39
  • 69
  • Possible duplicate of [git: sync local repo with remote one](https://stackoverflow.com/questions/6373277/git-sync-local-repo-with-remote-one) – phd Oct 23 '17 at 16:32

1 Answers1

0

Follow below steps to push changes without loosing any code

  1. Clone latest to some new folder
  2. Create a branch from master/develop so that master/develop branch is not disturbed. Let's say branch name jinnabalu/existing-sync
  3. Copy the files or folder to the repo cloned
  4. Check with the difference.

    git status

  5. Push your changes to your remote branch (jinnabalu/existing-sync)

git add --all

git commit -am "Sync local folder"

git push -u origin jinnabalu/existing-sync

  1. Merge your branch (jinnabalu/existing-sync) to master or develop from where you have created

git checkout master

git pull

git checkout jinnabalu/existing-sync

git merge --no-ff origin master

git checkout master

git merge --no-ff origin jinnabalu/existing-sync

Jinna Balu
  • 6,747
  • 38
  • 47