5

I rename repos on BitBucket and and get error when I try to push again. I renamed one repo and now see:

cchilders:~/projects/gitflow_automation (master) 
$ showorigin 
repository does not exist.
fatal: Could not read from remote repository.

So I do

$ rm -rf .git
$ git init
$ git remote add origin git@bitbucket.org:codyc54321/gitflow_automation.git

This adds the newly named repo (the same repo though, just new name) to the new .git files.

I then did

cchilders:~/projects/gitflow_automation 
$ showorigin 
* remote origin
  Fetch URL: git@bitbucket.org:codyc54321/gitflow_automation.git
  Push  URL: git@bitbucket.org:codyc54321/gitflow_automation.git
  HEAD branch: master
  Remote branch:
    master new (next fetch will store in remotes/origin)

cchilders:~/projects/gitflow_automation 
$ git pull
remote: Counting objects: 70, done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 70 (delta 20), reused 0 (delta 0)
Unpacking objects: 100% (70/70), done.
From bitbucket.org:codyc54321/gitflow_automation
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


cchilders:~/projects/gitflow_automation 
$ nano FAKE

cchilders:~/projects/gitflow_automation 
$ cmpushall "test new repo name working"
[master (root-commit) 7b0a190] test new repo name working
 21 files changed, 601 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 FAKE
 create mode 100644 README.md
 create mode 100644 __init__.py
 create mode 100644 gitflow/__init__.py
 create mode 100644 gitflow/client.py
 create mode 100644 gitflow/config/__init__.py
 create mode 100644 gitflow/github_webdriver_client/__init__.py
 create mode 100644 gitflow/pivotal_tracker_webdriver_client/__init__.py
 create mode 100644 gitflow/user.py
 create mode 100644 gitflow/webdriver_base/__init__.py
 create mode 100644 requirements.txt
 create mode 100755 scripts/make_stories.py
 create mode 100755 scripts/open_pull_request.py
 create mode 100755 scripts/open_pull_request.sh
 create mode 100644 tests/__init__.py
 create mode 100644 tests/test_github_user_login_info.py
 create mode 100644 tests/test_github_webdriver_client/__init__.py
 create mode 100644 tests/test_github_webdriver_client/test_github_driver.py
 create mode 100644 tests/test_pivotal_tracker_webdriver_client/__init__.py
 create mode 100644 tests/test_pivotal_tracker_webdriver_client/test_pivotal_tracker_driver.py
To bitbucket.org:codyc54321/gitflow_automation.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@bitbucket.org:codyc54321/gitflow_automation.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

cchilders:~/projects/gitflow_automation (master) 
$ git fetch 

cchilders:~/projects/gitflow_automation (master) 
$ git pull

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

Causing this problem:

cchilders:~/projects/gitflow_automation (master) 
$ git pull origin  master 
From bitbucket.org:codyc54321/gitflow_automation
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Is there a way to rename a repo on BitBucket or GitHub?

halfer
  • 19,824
  • 17
  • 99
  • 186
codyc4321
  • 9,014
  • 22
  • 92
  • 165

3 Answers3

10

To update the remote url in your local repository run (for ssh):

git remote set-url origin git@git***.com:owner/project_name.git

or for http(s):

git remote set-url origin https://git***.com/nh-ad/dynamic-audiance-segment.git
Ankit Raj
  • 196
  • 1
  • 4
1

I don't know if its going to work but i guess you can try these,

Try git pull --rebase

see this link

You can use --allow-unrelated-histories to force the merge to happen like this

git pull origin branchname --allow-unrelated-histories

Hope this helps.

Community
  • 1
  • 1
Danish
  • 1,467
  • 19
  • 28
0

Danish's git pull origin master --allow-unrelated-histories worked:

enter image description here

showing some weird detached part rejoined, where I had renamed it and deleted .git

codyc4321
  • 9,014
  • 22
  • 92
  • 165