xxxxxxxx@open02:~/src/code/tmp$ git clone git@gitee.com:striver-wy/test-code.git //从gitee下载代码
Cloning into 'test-code'...
remote: Enumerating objects: 49, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 49 (delta 9), reused 0 (delta 0), pack-reused 12
Receiving objects: 100% (49/49), 10.45 KiB | 1.49 MiB/s, done.
Resolving deltas: 100% (14/14), done.
xxxxxxxx@open02:~/src/code/tmp$ ls
test-code
xxxxxxxx@open02:~/src/code/tmp$ cd test-code/
xxxxxxxx@open02:~/src/code/tmp/test-code$ git remote -v //查看原始的origin
origin ?git@gitee.com:striver-wy/test-code.git (fetch)
origin ?git@gitee.com:striver-wy/test-code.git (push)
xxxxxxxx@open02:~/src/code/tmp/test-code$ git branch -a //查看所有分支
* master ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //本地已有master分支代码,但是test分支代码还没有
? remotes/origin/HEAD -> origin/master
? remotes/origin/master
? remotes/origin/test
xxxxxxxx@open02:~/src/code/tmp/test-code$ ?git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote";done //获取所有远程分支到本地
fatal: a branch named 'master' already exists
branch 'test' set up to track 'origin/test'.
xxxxxxxx@open02:~/src/code/tmp/test-code$ git branch
* master
? test
xxxxxxxx@open02:~/src/code/tmp/test-code$ git branch -a
* master--------------------------------------》master 本地分支已有
? test ? ? ? ? ? ? ? ? --------------------------------------------------------》此时test分支已下载到本地
? remotes/origin/HEAD -> origin/master
? remotes/origin/master
? remotes/origin/test
xxxxxxxx@open02:~/src/code/tmp/test-code$ git fetch --all--------------------------》 #获取该项目远程库的所有分支及其内容
Fetching origin
xxxxxxxx@open02:~/src/code/tmp/test-code$ git fetch --tags---------------------------》 ?#获取该项目远程库的标签
xxxxxxxx@open02:~/src/code/tmp/test-code$ ls
devmem-test ?README.en.md ?README.md ?sample ?test-assemble
xxxxxxxx@open02:~/src/code/tmp/test-code$ git branch -a
* master
? test
? remotes/origin/HEAD -> origin/master
? remotes/origin/master
? remotes/origin/test
xxxxxxxx@open02:~/src/code/tmp/test-code$ git remote -v
origin ?git@gitee.com:striver-wy/test-code.git (fetch)
origin ?git@gitee.com:striver-wy/test-code.git (push)
xxxxxxxx@open02:~/src/code/tmp/test-code$ git remote rename origin old-origin------------------》#将原来的origin重命名一下
xxxxxxxx@open02:~/src/code/tmp/test-code$ ?git remote add origin git@172.28.3.77:xs-soc/test-code.git-----------------------》 #指定需要迁移到新的目标地址
xxxxxxxx@open02:~/src/code/tmp/test-code$ git remote -v------------------------------------》查看origin和old-origin
old-origin ? ? ?git@gitee.com:striver-wy/test-code.git (fetch)
old-origin ? ? ?git@gitee.com:striver-wy/test-code.git (push)
origin ?git@172.28.3.77:xs-soc/test-code.git (fetch)
origin ?git@172.28.3.77:xs-soc/test-code.git (push)
xxxxxxxx@open02:~/src/code/tmp/test-code$ ?git push origin --all------------------------------------------------》 #推送所有分支及其内容
Enumerating objects: 49, done.
Counting objects: 100% (49/49), done.
Delta compression using up to 256 threads
Compressing objects: 100% (26/26), done.
Writing objects: 100% (49/49), 10.44 KiB | 10.44 MiB/s, done.
Total 49 (delta 14), reused 49 (delta 14), pack-reused 0
remote:
remote: To create a merge request for test, visit:
remote: ? http://172.28.3.77:8989/xs-soc/test-code/-/merge_requests/new?merge_request%5Bsource_branch%5D=test
remote:
remote:
remote:
remote: The private project xs-soc/test-code was successfully created.
remote:
remote: To configure the remote, run:
remote: ? git remote add origin git@172.28.3.77:xs-soc/test-code.git
remote:
remote: To view the project, visit:
remote: ? http://172.28.3.77:8989/xs-soc/test-code
remote:
remote:
remote:
To 172.28.3.77:xs-soc/test-code.git
?* [new branch] ? ? ?master -> master
?* [new branch] ? ? ?test -> test
xxxxxxxx@open02:~/src/code/tmp/test-code$ ?git push --tags-------------------------------------》 #推送所有标签及其内容
Everything up-to-date
xxxxxxxx@open02:~/src/code/tmp/test-code$
?