Moving git repository and all its branches, tags to a new remote repository keeping commits history
来源:互联网 发布:淘宝售后期限是多久 编辑:程序博客网 时间:2024/04/29 02:12
#!/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 and tags: 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 git@github.com: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.
0 0
- Moving git repository and all its branches, tags to a new remote repository keeping commits history
- Setting up a new remote git repository
- setting up a new remote git repository
- How to Push a New Local Branch to a Remote Git Repository
- Git_Clone a remote git repository and cd into it
- Git Create a new repository
- Git: Setup a remote Git repository
- Interactive between local repository and remote repository in git
- Git 提示 No remote repository specified. Please, specify either a URL or a remote name from which new
- how to clone all remote branches in git
- Git HowTo: revert a commit already pushed to a remote repository
- PULL A NEW BRANCH FROM A REMOTE REPOSITORY
- git No remote repository specified
- git remote: Repository not found.
- Upload local Git repository to remote using IntelliJ IDEA plugin
- ShmooCon IX: Moloch: A New And Free Way To Index Your Packet Capture Repository
- Git - Splitting a subfolder out into a new repository
- clone & push all remote branches with git
- 打了激素的数组
- HDU_2899_Strange fuction
- NSFileManager文件的创建复制删除遍历 NSFileHandler读取关闭同步 NSUserDefault(类似android shreapreference) plist属性列表
- hashmap冲突的解决方法以及原理分析
- 输入输出流简单理解
- Moving git repository and all its branches, tags to a new remote repository keeping commits history
- CVPR 2016-9-30
- 第六周【项目一-建立顺序列环形算法库】
- Java中队列的实现(1)-使用顺序存储结构(数组)以及实现
- PAT_A 1112. Stucked Keyboard (20)
- 怎样查看QQ撤回图片
- Thread和Runnable理解
- hdu---2015做题笔记
- 欢迎使用CSDN-markdown编辑器