当前位置:   article > 正文

git push 与 仓库迁移_git push --mirror

git push --mirror

前言

Git提交纪录是项目的灵魂。

前段时间,因为某些特定原因。导致需要进行仓库的迁移。但是又想保留原有的提交纪录。于是查询了下,发现有git push --mirror命令可以完美符合我的要求。


操作过程

  • 通过cd命令到达本地仓库的.git路径下;
  • 在远端新建一个仓库,比如我在github上建立了bigdata仓库;
  • 通过git push --mirror https://github.com/SeanYanxml/bigdata.git将本地仓库推送到远端的仓库;
  • 从远端下载。

附:

  1. 发现之前的项目经理没有使用这样的流程导致很多的提交纪录丢失了,应该算作工作的失误了。
  2. 其次,项目重构也会导致提交纪录的丢失。这对于项目经理,也就是项目的管理者是一件至关重要的事情。(重构的提交纪录的管理措施暂时没有想到好的办法。)

操作记录

localhost:Gitrep Sean$ cd bigdata
localhost:bigdata Sean$ ls
README.md	apps		kafka		mongodb		pom.xml		redis		spark		spark-redis	spark-streaming	word2vec	zookeeper
localhost:bigdata Sean$ ls -a
.		.DS_Store	.git		.project	README.md	kafka		pom.xml		spark		spark-streaming	zookeeper
..		.classpath	.gitignore	.settings	apps		mongodb		redis		spark-redis	word2vec
localhost:bigdata Sean$ cd .git
localhost:.git Sean$ ls
COMMIT_EDITMSG		ORIG_HEAD		description		info			packed-refs
FETCH_HEAD		branches		hooks			logs			refs
HEAD			config			index			objects			sourcetreeconfig
localhost:.git Sean$ git push --mirror https://github.com/SeanYanxml/bigdata.git
Counting objects: 714, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (502/502), done.
Writing objects: 100% (714/714), 238.09 KiB | 0 bytes/s, done.
Total 714 (delta 176), reused 0 (delta 0)
remote: Resolving deltas: 100% (176/176), done.
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/SeanYanxml/bigdata/pull/new/master
remote:
To https://github.com/SeanYanxml/bigdata.git
 * [new branch]      master -> master
localhost:.git Sean$ git log
commit 7af660c5064440edad9dbe72991beac5b9dad518
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Nov 14 22:06:10 2018 +0800

    Update last commit.

commit e7edf73121aac282f8a0ab9e80aa9db06fe8dc83
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Nov 14 22:05:52 2018 +0800

    Spark Streaming & Mongodb Init.

commit d211ac5c2518c5516f9e27388137990cc63ef4af
Author: Sean Yan <huaianyanxu@163.com>
Date:   Sat Aug 4 23:15:16 2018 +0800

    Kafka consumer & provider demo.

commit 000e015bf10cb3f1b0d5289b53f2145641f41b85
Author: Sean Yan <huaianyanxu@163.com>
Date:   Thu Aug 2 15:52:19 2018 +0800

    The queue demo of zk.

commit 85bb3d670e4e3ef29aa7a71f55395289c14eb189
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Aug 1 15:23:35 2018 +0800

    The demo of the zk demos - balance.

commit 049b90f5b0e82e29e87dc1a0c41765da775f7172
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Aug 1 00:57:37 2018 +0800

    Half of the code of the zk demo balance .

commit 6cf6ecf50a0be05f14e93afee4b276295190aa25
Author: Sean Yan <huaianyanxu@163.com>
Date:   Tue Jul 31 11:02:26 2018 +0800

    Distribute service of zk.

commit e48be11333c4e37aba4dbc12204575b431d4c483
Author: Sean Yan <huaianyanxu@163.com>
Date:   Tue Jul 31 00:02:21 2018 +0800

    The lock demo of zk.

commit 8c0c4b7d7d213aadea31c818aae7e1c4299183a6
Author: Sean Yan <huaianyanxu@163.com>
Date:   Mon Jul 30 17:33:35 2018 +0800

    ZK Demos 2: subscribe.

commit 22d06a128269260fb0f2000458eef025efd489c9
Author: Sean Yan <huaianyanxu@163.com>
Date:   Mon Jul 30 14:46:29 2018 +0800

    Update the struct of the project zk-demo.

commit d70e4718dbe1b4d6a1b1592b26fda3f38b6cbf24
Author: Sean Yan <huaianyanxu@163.com>
Date:   Mon Jul 30 14:40:57 2018 +0800

localhost:.git Sean$  git rebase -i HEAD~100
fatal: Needed a single revision
invalid upstream HEAD~100
localhost:.git Sean$  git rebase -i HEAD~20
fatal: This operation must be run in a work tree
fatal: This operation must be run in a work tree
Cannot rebase: You have unstaged changes.
Please commit or stash them.
localhost:.git Sean$ git log
commit 7af660c5064440edad9dbe72991beac5b9dad518
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Nov 14 22:06:10 2018 +0800

    Update last commit.

commit e7edf73121aac282f8a0ab9e80aa9db06fe8dc83
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Nov 14 22:05:52 2018 +0800

    Spark Streaming & Mongodb Init.

commit d211ac5c2518c5516f9e27388137990cc63ef4af
Author: Sean Yan <huaianyanxu@163.com>
Date:   Sat Aug 4 23:15:16 2018 +0800

    Kafka consumer & provider demo.

commit 000e015bf10cb3f1b0d5289b53f2145641f41b85
Author: Sean Yan <huaianyanxu@163.com>
Date:   Thu Aug 2 15:52:19 2018 +0800

    The queue demo of zk.

commit 85bb3d670e4e3ef29aa7a71f55395289c14eb189
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Aug 1 15:23:35 2018 +0800

    The demo of the zk demos - balance.

commit 049b90f5b0e82e29e87dc1a0c41765da775f7172
Author: Sean Yan <huaianyanxu@163.com>
Date:   Wed Aug 1 00:57:37 2018 +0800

    Half of the code of the zk demo balance .

commit 6cf6ecf50a0be05f14e93afee4b276295190aa25
Author: Sean Yan <huaianyanxu@163.com>
Date:   Tue Jul 31 11:02:26 2018 +0800

    Distribute service of zk.
edit bdb4997 The action to simulate the vote for leader.

commit e48be11333c4e37aba4dbc12204575b431d4c483
Author: Sean Yan <huaianyanxu@163.com>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144

Q&A

  • 新项目的远端分支是否和本地一样?

未知


Reference

[1] 从一个git仓库迁移到另外一个git仓库


后记 20210128

温故而知新,可以为师也。今天有个朋友留言提问。git push --mirrorgit push有什么区别?

  • git push <origin> <master> 拷贝和提交某个分支.
  • git push --mirror <remote-git-url> 拷贝所有分支.
--mirror
Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.
  • 1
  • 2
  • Others git push --mirror VS git push --all?

https://git-scm.com/docs/git-push
Git命令大全
git push 命令
git push --mirror $URL
如何迁移一个Git仓库
如何使用push将一个git远程镜像到另一个远程镜像
git push --mirror $URL
git push命令

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/507809
推荐阅读
相关标签
  

闽ICP备14008679号