Merging two identical codebases

I'm test-driving a switch to git for our version control system (using SVN now), and having some issues managing a remote repository on Bitbucket. Two team members have the codebase for a project checked out, and we'd like to add the codebase to Bitbucket. We've both created git repos, but are unable to push to the same branch on Bitbucket. The only way to commit is to pull down from the remote repo first, which I'm hesitant to do (overwriting settings files etc.)

We also tried to push to two separate branches, and then merge, but it says the commits are unrelated and can't merge. I'm new to git, so I might be missing something obvious, but are there specific reasons I'm having such a hard time merging identical codebases in BitBucket?

1 answer

1 accepted

0 votes
Answer accepted

Before starting to apply what I wrote next, please make a backup. I don't know if I understood correctly what you need and something might break. That being said, lets give it a try.

Take the codebase from SVN and create a local git repository:

$ cd /path/to/src
$ git init

Start tracking the files:

$ git add

Make your first commit:

$ git commit -am "Initial import from SVN"

Add bitbucket as remote:

$ git remote add origin ssh://<username>/<repo>.git

And finally push everything:

$ git push -u origin --all

Then your second team member can pull existing codebase, make his changes in a separate branch, merge them back in the development branch and in the end push them to remote and send pull request if necessary. To make thing easier, you can use [gitflow](

What I explained above regarding your colleague, can be done using gitflow like this:

# clone existing repo
$ git clone ssh://<username>/<repo>.git

# enable gitflow
$ git flow init

# start a new branch called "start my_super_feature"
$ git flow feature start my_super_feature

# make code changes, commit them, write awesome code

# when you are done, merge the branch where you worked in the development branch
$ git flow feature finish my_super_feature

At this point your colleague will have in the development branch your changes (from cloning) and his changes on top of yours. Now he can push the changes back to origin.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

304 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you