How to move a git folder repository to git repository without losing the history.

Here in the scenario, what I have was a folder repository where users will commit the changes. Users will treat the folder which is in a network location and will commit the changes to this repository. Now I want this to be moved to a bit bucket server so that I can use the proper process to get the changes merged. Here the challenge is to retain the history of changes without losing it while porting. Let’s see how this can be achieved. for this what we need is

  • Existing repository URL
  • A new blank repository in bitbucket.
  • Source tree(optional)

Create a blank repository in bitbucket. This is the repository where you want to move the folder repository. Now once the repository is created, clone this to local. Once it is cloned, open the terminal from source tree. [If you don’t have source tree then use a command prompt and cd into the local repository folder]. Now run the below command to add a remote to the repository.

git remote add -f old_repo OLD-FOLDER-REPO-URL

here old_repo is the name give to the remote and it can be anything. OLD-FOLDER-REPO-URL is the folder path to the .git folder(for folder repository. e.g. “W:\Folder\.git”). Make sure that the path is escaped of special characters. This includes the back slash such that the path will look like, as in example, W:\\Folder\\.git The command will take some time to execute depending on how big the repository is. In case if you want to remove the new remote, then use command “git remote -v” to list all the remotes and use “git remote rm old_repo” to delete it.

Capture1.JPG

Now use the below command to merge the desired branch from old repository to new one by running the below command. Here the BRANCH-NAME should be replaced with the desired branch name in old repository. This will merge the branch to current branch in new repository. Since it is new and blank repository, it will be merged to mater branch.

git merge old_repo/BRANCH-NAME

Now we are done, we will have to now push the changes to origin master. In Source tree do a push to master. [on command line run “git push origin master”]

Capture.JPG

Now the changes including the history is pushed to server. Now you can manage the permission and control the merges to master via pull requests.

Setting Up Kafka

Apache Kafka is a high-throughput, low-latency event processing system designed to handle millions of data feeds per second. It has the c...… Continue reading

Libish Varghese Jacob

Libish Varghese JacobI am currently working as a lead engineer in one of the leading wind turbine manufacturing firm. I have wide range of interests and getting my hands dirty in technology is one among them. I use this platform primarily as my knowledge base. I also use this platform to share my experience and experiments so that it might help someone who is walking the way I already did. The suggestions expressed here are the best to my knowledge at the time of writing and this may not necessarily be the best possible solution. I would pretty much appreciate if you could comment on it to bring into my notice on what could have been done better.