欢迎光临散文网 会员登陆 & 注册

Git基本操作

2020-06-23 00:59 作者:无情剑客Burning  | 我要投稿

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git 常用的指令和定义

Git操作

  1. $ git log

  2. commit 65901b6c3d9b366788ceffd9c6905b12e34d7068 (HEAD -> a1)

  3. Author: Burning Teng <2250911301@qq.com>

  4. Date:   Thu Jan 2 22:33:56 2020 +0800


  5.    a1*4


  6. commit dbc6f316e6b3c3c23905fe2b8035a3acafe9d4b3

  7. Author: Burning Teng <2250911301@qq.com>

  8. Date:   Thu Jan 2 22:32:26 2020 +0800


  9.    a1*3


  10. commit e93ff79c9c9a4fd7de4938fdcf128923a3eb669a

  11. Author: Burning Teng <2250911301@qq.com>

  12. Date:   Thu Jan 2 22:31:09 2020 +0800


  13.    a1*2


  14. commit fe3f58bec8a08ea618f65a87c70ec72d507c2e0a (master)

  15. Author: Burning Teng <2250911301@qq.com>

  16. Date:   Thu Jan 2 01:10:59 2020 +0800


  17.    a1+a1


  18.    a1+a1+a1


  19.    a1+a1+a1+a1


  20.    a1+a1+a1+a1+a1


  21.    a1*6


  22.    a1*4


  23. commit 6e8da3d08c7f008eb8f9702f3ee970c90b37325b

  24. Author: Burning Teng <2250911301@qq.com>

  25. Date:   Thu Jan 2 01:10:27 2020 +0800


  26.    a1

无论是修改commit的顺序还是修改commit信息,commit对应的文件信息等,都可以使用git rebase -i 来完成。

  1. $ git rebase -i 6e8da3d08c7f008eb8f9702f3ee970c90b37325b

  2. [detached HEAD e5f7eae] a1 no2

  3. Date: Thu Jan 2 01:10:59 2020 +0800

  4. 1 file changed, 1 insertion(+), 1 deletion(-)

  5. Stopped at e93ff79...  a1*2

  6. You can amend the commit now, with


  7.  git commit --amend


  8. Once you are satisfied with your changes, run


  9.  git rebase --continue


  10. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  11. $ git branch

  12. * (no branch, rebasing a1)

  13.  a1

  14.  master


  15. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  16. $ ls

  17. a.txt


  18. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  19. $ vi a.txt


  20. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  21. $ git commit --amend

  22. [detached HEAD 43cccc5] a1*2 no3

  23. Date: Thu Jan 2 22:31:09 2020 +0800

  24. 1 file changed, 1 insertion(+), 1 deletion(-)


  25. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  26. $ git branch

  27. * (no branch, rebasing a1)

  28.  a1

  29.  master


  30. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  31. $ git status

  32. interactive rebase in progress; onto 6e8da3d

  33. Last commands done (2 commands done):

  34.   reword fe3f58b a1+a1

  35.   edit e93ff79 a1*2

  36. Next commands to do (2 remaining commands):

  37.   pick dbc6f31 a1*3

  38.   pick 65901b6 a1*4

  39.  (use "git rebase --edit-todo" to view and edit)

  40. You are currently editing a commit while rebasing branch 'a1' on '6e8da3d'.

  41.  (use "git commit --amend" to amend the current commit)

  42.  (use "git rebase --continue" once you are satisfied with your changes)


  43. nothing to commit, working tree clean


  44. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)

  45. $ git rebase --continue

  46. Successfully rebased and updated refs/heads/a1.


  47. Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1)

  48. $ git log --oneline

  49. 22894ce (HEAD -> a1) a1*4

  50. 56fec42 a1*3

  51. 43cccc5 a1*2 no3

  52. e5f7eae a1 no2

  53. 6e8da3d a1

Git补充指令

git remote rm origin

公众号

微信公众号:无情剑客




Git基本操作的评论 (共 条)

分享到微博请遵守国家法律