Move git repository

Sometimes it is necessary to move the location of a git repository; be it from one GitHub repo to another or moving a repo from GitHub to Bitbucket. This can be surprisingly tricky since one needs to make sure to include all branches, tags, etc. when copying the data.

Thankfully git magic allows doing this fairly easily. Just run the following commands:

git clone --mirror <old-repo-url>
cd <repo-name>
git remote add new-origin <new-repo-url>
git push new-origin --mirror

That should be it!

Note that if you are copying a GitHub repo you might get lovely messages such as the following. That should be fine and nothing to worry about.

 ! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/10/head -> refs/pull/10/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/100/head -> refs/pull/100/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/101/head -> refs/pull/101/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/102/head -> refs/pull/102/head (deny updating a hidden ref)

 

Fix Travis CI Error ‘This is not an active repository’

Problem

Your repositories have been building just fine using the tool Travis CI but suddenly the builds do not work anymore and the Travis CI website shows a screen with the message:

`This is not an active repository`

active

Solution

  • Go to GitHub and assure that you are logged in with the account that owns the repository.
  • Go to Travis CI and sign in with your GitHub account
  • Go to the repository
  • Click on the button ‘Active Repository’

If all works, that’s fine. However, if you get an error: ‘There was an error while trying to activate the repository.’ do the following:

  • Go to the settings for your account on Travis – Assure that the repository you want to build is enabled.

References

Travis CI Issue #5629

StackOverflow `Seeing “This is not an active repository” for an active repository`

Import GitHub project to Android Studio

Problem

You have an existing GitHub project and would like to import it to Android Studio.

Solution

Perform the following steps to import your project.

Step 1: Install git for Windows

It can be downloaded for free from git-scm.com.

Most settings available during the installation process should be compatible with Android studio. Just choose the settings you deem the most appropriate.

Step 2: Link git executable to Android Studio

Open Android Studio and got to Settings. In the Setting dialog open the page Version Control / Git. Here define the path to the git executable you have just installed.

Step 3: Get the Path to your Repository from Github

Go to the GitHub page and get the HTTPs path to your repository. For instance:

https://github.com/mxro/WallOfTheWiseAndroid.git

Step 4: Import the Git project to Android Studio

Go to Android Studio and go to Menu / VCS / Checkout from Version Control / Git

Paste the HTTPS path you obtained from GitHub in the previous step and click on [Clone].

Provide your GitHub username and password.

Now the project should be imported to Android Studio and you should be able to commit and push future changes back to GitHub.

References

Android Studio Git Tutorial (Part 1) « Wii’s Blog

github – How to clone a remote git repository with Android Studio? – Stack Overflow

Setup Android Developer Studio | devroyal.de