git push 与 仓库迁移

版权声明:欢迎转载,转载请说明出处https://csdn.yanxml.com。大数据Github项目地址https://github.com/SeanYanxml/bigdata。 https://blog.csdn.net/u010416101/article/details/84558855

前言

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 <[email protected]>
Date:   Wed Nov 14 22:06:10 2018 +0800

    Update last commit.

commit e7edf73121aac282f8a0ab9e80aa9db06fe8dc83
Author: Sean Yan <[email protected]>
Date:   Wed Nov 14 22:05:52 2018 +0800

    Spark Streaming & Mongodb Init.

commit d211ac5c2518c5516f9e27388137990cc63ef4af
Author: Sean Yan <[email protected]>
Date:   Sat Aug 4 23:15:16 2018 +0800

    Kafka consumer & provider demo.

commit 000e015bf10cb3f1b0d5289b53f2145641f41b85
Author: Sean Yan <[email protected]>
Date:   Thu Aug 2 15:52:19 2018 +0800

    The queue demo of zk.

commit 85bb3d670e4e3ef29aa7a71f55395289c14eb189
Author: Sean Yan <[email protected]>
Date:   Wed Aug 1 15:23:35 2018 +0800

    The demo of the zk demos - balance.

commit 049b90f5b0e82e29e87dc1a0c41765da775f7172
Author: Sean Yan <[email protected]>
Date:   Wed Aug 1 00:57:37 2018 +0800

    Half of the code of the zk demo balance .

commit 6cf6ecf50a0be05f14e93afee4b276295190aa25
Author: Sean Yan <[email protected]>
Date:   Tue Jul 31 11:02:26 2018 +0800

    Distribute service of zk.

commit e48be11333c4e37aba4dbc12204575b431d4c483
Author: Sean Yan <[email protected]>
Date:   Tue Jul 31 00:02:21 2018 +0800

    The lock demo of zk.

commit 8c0c4b7d7d213aadea31c818aae7e1c4299183a6
Author: Sean Yan <[email protected]>
Date:   Mon Jul 30 17:33:35 2018 +0800

    ZK Demos 2: subscribe.

commit 22d06a128269260fb0f2000458eef025efd489c9
Author: Sean Yan <[email protected]>
Date:   Mon Jul 30 14:46:29 2018 +0800

    Update the struct of the project zk-demo.

commit d70e4718dbe1b4d6a1b1592b26fda3f38b6cbf24
Author: Sean Yan <[email protected]>
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 <[email protected]>
Date:   Wed Nov 14 22:06:10 2018 +0800

    Update last commit.

commit e7edf73121aac282f8a0ab9e80aa9db06fe8dc83
Author: Sean Yan <[email protected]>
Date:   Wed Nov 14 22:05:52 2018 +0800

    Spark Streaming & Mongodb Init.

commit d211ac5c2518c5516f9e27388137990cc63ef4af
Author: Sean Yan <[email protected]>
Date:   Sat Aug 4 23:15:16 2018 +0800

    Kafka consumer & provider demo.

commit 000e015bf10cb3f1b0d5289b53f2145641f41b85
Author: Sean Yan <[email protected]>
Date:   Thu Aug 2 15:52:19 2018 +0800

    The queue demo of zk.

commit 85bb3d670e4e3ef29aa7a71f55395289c14eb189
Author: Sean Yan <[email protected]>
Date:   Wed Aug 1 15:23:35 2018 +0800

    The demo of the zk demos - balance.

commit 049b90f5b0e82e29e87dc1a0c41765da775f7172
Author: Sean Yan <[email protected]>
Date:   Wed Aug 1 00:57:37 2018 +0800

    Half of the code of the zk demo balance .

commit 6cf6ecf50a0be05f14e93afee4b276295190aa25
Author: Sean Yan <[email protected]>
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 <[email protected]>


Q&A

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

未知


Reference

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

猜你喜欢

转载自blog.csdn.net/u010416101/article/details/84558855