$ git remote show origin #显示所有分支,并提示其状态
Remote branches:
master tracked
refs/remotes/originhttps/test stale (use 'git remote prune' to remove)
$ git remote prune origin #全部予以删除(也可指定具体分支进行操作)
Pruning origin
URL: https://github.com/xxxxxx/testgit.git
* [pruned] originhttps/test
二、如何把已经提交的commit, 从一个分支放到另一个分支
我们有时候会凌乱在几个分支中,把本来要提交到分支test的内容commit到了分支test2,此时,既不想在分支 test上重做,也不能合并过去,怎么办:
$git status
On branch test2
Your branch is ahead of 'originhttps/test2' by 1 commit.
(use "git push" to publish your local commits)
Your branch is ahead of 'originhttps/test2' by 1 commit.
(use "git push" to publish your local commits)
而其实我希望将这个commit做到test1上面的
$ git checkout test1
$ git cherry-pick 50db69485
[test1 e7574ee] this is a mistack
Date: Sun Mar 12 08:36:54 2017 +0800
1 file changed, 1 insertion(+)
create mode 100644 iwant2commit2test1
[test1 e7574ee] this is a mistack
Date: Sun Mar 12 08:36:54 2017 +0800
1 file changed, 1 insertion(+)
create mode 100644 iwant2commit2test1
三、修改已经commit的内容
曾经包含敏感信息的内容直接commit的筒子们举个手,往往commit甚至push之后发现备注写错了字或者提交文件中有密码。这时还有救吗?
$ git show 2d91ccfcf
commit 2d91ccfcf8b25b27b7245077a7654eb799ff58f5
Author: XXXX <xxxxxxxxxxxx@126.com>
Date: Sun Mar 12 08:49:31 2017 +0800
typo in comment
diff --git a/sensitive_file b/sensitive_file
new file mode 100644
index 0000000..05e7a00
--- /dev/null
+++ b/sensitive_file
@@ -0,0 +1 @@
+this is my db password
commit 2d91ccfcf8b25b27b7245077a7654eb799ff58f5
Author: XXXX <xxxxxxxxxxxx@126.com>
Date: Sun Mar 12 08:49:31 2017 +0800
typo in comment
diff --git a/sensitive_file b/sensitive_file
new file mode 100644
index 0000000..05e7a00
--- /dev/null
+++ b/sensitive_file
@@ -0,0 +1 @@
+this is my db password
继续修改文件内容后,git add 后执行
$ git commit --amend
$ git log
commit e84762041f68e210b65c463007d2349b86b92135
Author: XXXX <xxxxxxxxxxxxxxxxxx@126.com>
Date: Sun Mar 12 08:49:31 2017 +0800
changed the commit comment
commit e84762041f68e210b65c463007d2349b86b92135
Author: XXXX <xxxxxxxxxxxxxxxxxx@126.com>
Date: Sun Mar 12 08:49:31 2017 +0800
changed the commit comment
$ git show e84762041f
commit e84762041f68e210b65c463007d2349b86b92135
Author: XXXX <xxxxxxxxxxxxxxxx@126.com>
Date: Sun Mar 12 08:49:31 2017 +0800
changed the commit comment
diff --git a/sensitive_file b/sensitive_file
new file mode 100644
index 0000000..9e0708f
--- /dev/null
+++ b/sensitive_file
@@ -0,0 +1 @@
+my db password deleted
commit e84762041f68e210b65c463007d2349b86b92135
Author: XXXX <xxxxxxxxxxxxxxxx@126.com>
Date: Sun Mar 12 08:49:31 2017 +0800
changed the commit comment
diff --git a/sensitive_file b/sensitive_file
new file mode 100644
index 0000000..9e0708f
--- /dev/null
+++ b/sensitive_file
@@ -0,0 +1 @@
+my db password deleted
$git push --force
------the end---