Reputation: 12447
I created a new Bitbucket repo, and by default it created it with a .gitignore
.
I have a large project not yet in source control.
This doc says to do the following:
git init
git add --all
git commit -m "Initial Commit"
git remote add origin https://[email protected]:7999/yourproject/repo.git
git push -u origin master
The push failed and said needed to pull.
git pull
gave this error:
There is no tracking information for the current branch.
So I googled it and did this:
git branch --set-upstream-to=origin/master master
Now I can do git pull
, but I get this error:
fatal: refusing to merge unrelated histories
This:
git push --force origin master
Didn't work as we are not allowed to push directly to master or develop, I tried this:
git checkout -b feature/1-initial
git push origin feature/1-initial
Then Bitbucket lets me create a PR, but says "Something went wrong Unrelated branches" no matter if I select develop or master.
Maybe I should start again like this:
.git
dirs from current project (will this work?)develop
I haven't heard of anyone doing this, but it seems the only tenable solution.
The big downside of this approach is I will lose all my IntelliJ config, including run profiles etc., as I will need to import a new project from scratch in the new dir.
Upvotes: -3
Views: 74
Reputation: 12447
The solution is this:
git init
in your current project dir.cd
to the new dirgit checkout develop
git checkout -b feature/1-initial
git add
, commit
and push
to originThe instructions on the Bitbucket site are woeful.
Upvotes: -1
Reputation: 7130
When you created a repo on Bitbucket with a .gitignore, Bitbucket created the repo for you with an initial commit to record the addition of the .gitignore
file.
This commit is only present in the history of your remote repository, hence it is unrelated to the history of your local repository. Since there is really not that much history going on on your remote, you could force push to overwrite the history of the remote's master
branch with your local master
branch.
git push --force origin master
However, in case the .gitignore
was defined only on the remote and you're interested in preserving it, make sure to download it or copy its content before proceeding with the push.
Alternatively, if you have protection rules in place (and as you've already mentioned after your edit), you can:
temp
from master
.temp
to the remote repository.temp
to master
.Upvotes: 1