> For the complete documentation index, see [llms.txt](https://lamhung81-2.gitbook.io/github-basic-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lamhung81-2.gitbook.io/github-basic-tutorial/git-how-to.md).

# GIT - move a full git repository from one remote sever to another one

## Copied [from](https://www.atlassian.com/git/tutorials/git-move-repository) <a href="#repo-command-line-instructions" id="repo-command-line-instructions"></a>

Let’s call the original repository ORI and the new one NEW, here are the steps required to copy everything from ORI to NEW:

1. Create a local repository in the **temp-dir** directory using:

```
git clone <url  to ORI repo >  temp-dir
```

![clone ori repository](https://wac-cdn.atlassian.com/dam/jcr:9fb5cea3-dcd6-4743-b847-a852a9683d47/clone-ori-repo.png?cdnVersion=le)

1. Go into the temp-dir directory.
2. To see a list of the different branches in ORI do:

```
git branch -a
```

![git branch-a](https://wac-cdn.atlassian.com/dam/jcr:38e6c2f1-cfc8-47a7-9391-66944c0eacdf/git-branch-a.png?cdnVersion=le)

1. Checkout all the branches that you want to copy from ORI to NEW using:

```
git checkout branch- name
```

![checkout-branches](https://wac-cdn.atlassian.com/dam/jcr:f290a19a-3d8b-46ee-ad34-18269d659905/checkout-branches.png?cdnVersion=le)

1. Now fetch all the tags from ORI using:

```
git fetch --tags
```

![git-fetch-tags](https://wac-cdn.atlassian.com/dam/jcr:f933e76e-f773-4943-8bd2-935a696cea0d/git-fetch-tags.png?cdnVersion=le)

1. Before doing the next step make sure to check your local tags and branches using the following commands:

```
git  tag

git  branch -a
```

![git-tag-and-git-branch-a](https://wac-cdn.atlassian.com/dam/jcr:789cf04f-ed2c-4ef8-8299-138b460b9751/git-tag-and-git-branch-a.png?cdnVersion=le)

1. Now clear the link to the ORI repository with the following command:

```
git remote rm origin
```

1. Now link your local repository to your newly created NEW repository using the following command:

```
git remote add  origin <url toNEW repo>
```

1. Now push all your branches and tags with these commands:

```
git push origin  --all


git push  --tags
```

![end-result](https://wac-cdn.atlassian.com/dam/jcr:2d1db8cb-7a28-46d0-8717-9afb0f1da244/end-result.png?cdnVersion=le)

1. You now have a full copy from your ORI repo.

## Command line instructions from GITLAB <a href="#repo-command-line-instructions" id="repo-command-line-instructions"></a>

### Git global setup

```
git config --global user.name "Lam Hung NGUYEN"
git config --global user.email "lamhung81@gmail.com"
```

### Create a new repository

```
git clone 
https://gitlab.com/lamhung81/auvfirmware.git

cd auvfirmware
touch README.md
git add README.md
git commit -m "add README"

git push -u origin master
```

### Existing folder

```
cd existing_folder
git init
git remote add origin 
https://gitlab.com/lamhung81/auvfirmware.git

git add .
git commit -m "Initial commit"

git push -u origin master
```

### Existing Git repository

```
cd existing_repo
git remote rename origin old-origin
git remote add origin 
https://gitlab.com/lamhung81/auvfirmware.git
git push -u origin --all
git push -u origin --tags
```
