It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Merging two identical codebases

Zach Weiler Sep 05, 2013

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
Alexandru G Sep 06, 2013

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://git@bitbucket.org/<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](https://github.com/nvie/gitflow).

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

# clone existing repo
$ git clone ssh://git@bitbucket.org/<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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

3,297 views 1 22
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you