日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

git-commit

發布時間:2024/10/12 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git-commit 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

git-commit

?

軟件版本:
  操作系統:ubuntu10.04
??? 內核版本:Linux version 2.6.32-36-generic
??? git 版本:git version 1.7.0.4

目錄:

  1. 文件狀態
  2. 提交
    2.1 git commit 與 git commit -a
    2.2 添加提交信息
  3. 修改/取消
  4. 參考資料

1. 文件狀態

  一般倉庫中的文件可能存在于這三種狀態:

??? 1)Untracked files → 文件未被跟蹤;
??? 2)Changes to be committed → 文件已暫存,這是下次提交的內容;
??? 3) Changes bu not updated → 文件被修改,但并沒有添加到暫存區。如果 commit 時沒有帶 -a 選項,這個狀態下的文件不會被提交。

$git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: file2
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: file
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file3

2. 提交

  git 提交的命令為:git commit 。

2.1 git commit 與 git commit -a

  git commit 提交的是暫存區里面的內容,也就是 Changes to be committed 中的文件。

$git commit
[master 5b61c29] run git commit
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file2

$git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: file
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file3

  git commit -a 除了將暫存區里的文件提交外,還提交 Changes bu not updated 中的文件。

$git commit -a
[master bd77524] run git commit -a
1 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 file2

$git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file3

2.2 添加提交信息

  如果直接運行 git commit (-a) 則會默認使用 vi 添加描述。也可以使用 git config --global core.editor 命令更改為你喜歡的編輯器。還有一個方法就是使用 -m 選項直接添加提交信息。

$git commit -a -m "commit info"

3. 修改/取消

  有時候我們會發現有幾個文件漏了提交或者想修改一下提交信息,又或者忘記使用 -a 選項導致一些文件沒有被提交,我們希望對上一次提交進行修改,或者說取消上一次提交,這時候我們需要使用 --amend 選項。

$git commit --amend

  可以對上一次提交進行修改,比如我們發現漏了 file3 沒有提交,我們可以運行一下操作:

$git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file3
nothing added to commit but untracked files present (use "git add" to track)

$git add file3
$git commit --amend
[master 671f5cc] commit --amend, add file3
1 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 file2
create mode 100644 file3

$git status
# On branch master
nothing to commit (working directory clean)

  又或者我們發現在提交時忘記使用 -a 選項,導致 Changes bu not updated 中的內容沒有被提交,我們可以使用:

$git commit --amend -a

4. 參考資料

[1] 《pro git》

轉載于:https://www.cnblogs.com/eddy-he/archive/2012/03/22/git_commit.html

總結

以上是生活随笔為你收集整理的git-commit的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。