Skip to content

Instantly share code, notes, and snippets.

@mtreml
Forked from niksumeiko/git.migrate
Last active June 21, 2019 16:29
Show Gist options
  • Save mtreml/192cae3efc08a89c0002aa0c035d9abf to your computer and use it in GitHub Desktop.
Save mtreml/192cae3efc08a89c0002aa0c035d9abf to your computer and use it in GitHub Desktop.

Revisions

  1. mtreml revised this gist Jun 21, 2019. 1 changed file with 0 additions and 11 deletions.
    11 changes: 0 additions & 11 deletions git.migrate
    Original file line number Diff line number Diff line change
    @@ -30,17 +30,6 @@ git checkout -b <branch> origin/<branch>
    # Check tags
    git fetch --tags

    # Apply & commit changes (optional)

    git rm -r building_od_ssd/
    git rm -r data/test_buildings.record
    git rm -r data/train_buildings.record
    git rm -r images/
    git rm -r tiles/
    git rm -r training/
    git rm -r ssd_inception_v2_coco_2017_11_17/

    git commit -a -m "Removed large files"

    ### Step 2. Add a "new repo" as a new remote origin:
    git remote add new-origin [email protected]:user/repo.git
  2. mtreml revised this gist Jun 20, 2019. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions git.migrate
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,12 @@
    #
    ### Step 1. Make sure you have a local copy of all "old repo"
    ### branches and tags.
    # Clone / cd to repo
    git clone ssh://git@git...
    cd <repo>

    # Do a backup

    # Fetch all of the remote branches and tags:
    git fetch origin

    @@ -21,6 +27,21 @@ git checkout -b <branch> origin/<branch>
    # Now we have to have all remote branches locally.


    # Check tags
    git fetch --tags

    # Apply & commit changes (optional)

    git rm -r building_od_ssd/
    git rm -r data/test_buildings.record
    git rm -r data/train_buildings.record
    git rm -r images/
    git rm -r tiles/
    git rm -r training/
    git rm -r ssd_inception_v2_coco_2017_11_17/

    git commit -a -m "Removed large files"

    ### Step 2. Add a "new repo" as a new remote origin:
    git remote add new-origin [email protected]:user/repo.git

  3. Nik Schumacher revised this gist Feb 13, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions git.migrate
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,12 @@
    # Let's assume we call "old repo" the repository you wish
    # to move, and "new repo" the one you wish to move to.
    #
    ### Step 1. Make sure you have a local copy of all 'old repo'
    ### Step 1. Make sure you have a local copy of all "old repo"
    ### branches and tags.
    # Fetch all of the remote branches:
    # Fetch all of the remote branches and tags:
    git fetch origin

    # View all 'old repo' local and remote branches:
    # View all "old repo" local and remote branches:
    git branch -a

    # If some of the remotes/ branches doesn't have a local copy,
  4. Nik Schumacher created this gist Feb 13, 2014.
    48 changes: 48 additions & 0 deletions git.migrate
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #!/bin/bash
    # Sometimes you need to move your existing git repository
    # to a new remote repository (/new remote origin).
    # Here are a simple and quick steps that does exactly this.
    #
    # Let's assume we call "old repo" the repository you wish
    # to move, and "new repo" the one you wish to move to.
    #
    ### Step 1. Make sure you have a local copy of all 'old repo'
    ### branches and tags.
    # Fetch all of the remote branches:
    git fetch origin

    # View all 'old repo' local and remote branches:
    git branch -a

    # If some of the remotes/ branches doesn't have a local copy,
    # checkout to create a local copy of the missing ones:
    git checkout -b <branch> origin/<branch>

    # Now we have to have all remote branches locally.


    ### Step 2. Add a "new repo" as a new remote origin:
    git remote add new-origin [email protected]:user/repo.git


    ### Step 3. Push all local branches and tags to a "new repo".
    # Push all local branches (note we're pushing to new-origin):
    git push --all new-origin

    # Push all tags:
    git push --tags new-origin


    ### Step 4. Remove "old repo" origin and its dependencies.
    # View existing remotes (you'll see 2 remotes for both fetch and push)
    git remote -v

    # Remove "old repo" remote:
    git remote rm origin

    # Rename "new repo" remote into just 'origin':
    git remote rename new-origin origin


    ### Done! Now your local git repo is connected to "new repo" remote
    ### which has all the branches, tags and commits history.