Git(2)-Git常用的操作和概念

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操作

$ git log
commit 65901b6c3d9b366788ceffd9c6905b12e34d7068 (HEAD -> a1)
Author: Burning Teng <[email protected]>
Date:   Thu Jan 2 22:33:56 2020 +0800

    a1*4

commit dbc6f316e6b3c3c23905fe2b8035a3acafe9d4b3
Author: Burning Teng <[email protected]>
Date:   Thu Jan 2 22:32:26 2020 +0800

    a1*3

commit e93ff79c9c9a4fd7de4938fdcf128923a3eb669a
Author: Burning Teng <[email protected]>
Date:   Thu Jan 2 22:31:09 2020 +0800

    a1*2

commit fe3f58bec8a08ea618f65a87c70ec72d507c2e0a (master)
Author: Burning Teng <[email protected]>
Date:   Thu Jan 2 01:10:59 2020 +0800

    a1+a1

    a1+a1+a1

    a1+a1+a1+a1

    a1+a1+a1+a1+a1

    a1*6

    a1*4

commit 6e8da3d08c7f008eb8f9702f3ee970c90b37325b
Author: Burning Teng <[email protected]>
Date:   Thu Jan 2 01:10:27 2020 +0800

    a1

無論是修改commit的順序還是修改commit信息,commit對應的文件信息等,都可以使用git rebase -i 來完成。

$ git rebase -i 6e8da3d08c7f008eb8f9702f3ee970c90b37325b
[detached HEAD e5f7eae] a1 no2
 Date: Thu Jan 2 01:10:59 2020 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)
Stopped at e93ff79...  a1*2
You can amend the commit now, with

  git commit --amend

Once you are satisfied with your changes, run

  git rebase --continue

Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)
$ git branch
* (no branch, rebasing a1)
  a1
  master

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

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

Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)
$ git commit --amend
[detached HEAD 43cccc5] a1*2 no3
 Date: Thu Jan 2 22:31:09 2020 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)

Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)
$ git branch
* (no branch, rebasing a1)
  a1
  master

Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)
$ git status
interactive rebase in progress; onto 6e8da3d
Last commands done (2 commands done):
   reword fe3f58b a1+a1
   edit e93ff79 a1*2
Next commands to do (2 remaining commands):
   pick dbc6f31 a1*3
   pick 65901b6 a1*4
  (use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'a1' on '6e8da3d'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

nothing to commit, working tree clean

Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1|REBASE-i 2/4)
$ git rebase --continue
Successfully rebased and updated refs/heads/a1.

Administrator@USERUSE-JBTODVE MINGW32 /i/kinggsoft/tt.txt (a1)
$ git log --oneline
22894ce (HEAD -> a1) a1*4
56fec42 a1*3
43cccc5 a1*2 no3
e5f7eae a1 no2
6e8da3d a1

Git補充指令

git remote rm origin

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章