1. 程式人生 > >Jenkins持續整合 之 git更改提交

Jenkins持續整合 之 git更改提交

Jenkins持續整合 之 git更改提交

git reset HEAD 檔名---將不必要的檔案移除暫存區

kangdeMacBook-Air:test1 kang$ echo "222" >> file2
kangdeMacBook-Air:test1 kang$ ls
file1   file2
kangdeMacBook-Air:test1 kang$ git add file2
drwxr-xr-x  13 kang  staff  442 12  2 15:13 .git
-rw-r--r--   1 kang  staff    4 12  2 15:13 file1
-rw-r--r--   1 kang  staff    4 12  2 15:13 file2
kangdeMacBook-Air:test1 kang$ git status
On branch master
Changes to be committed:
    (use "git reset HEAD <file>..." to unstage)

    new file:   file2

kangdeMacBook-Air:test1 kang$ git reset HEAD file2
kangdeMacBook-Air:test1 kang$ git status
On branch master
Untracked files:
    (use "git add <file>..." to include in what will be committed)

    file2

nothing added to commit but untracked files present (use "git add" to track)

git reset HEAD^---將最近的提交commit取消

kangdeMacBook-Air:test1 kang$ git add file2
kangdeMacBook-Air:test1 kang$ git commit -m "第二次提交"
[master ff57efb] 第二次提交
 Committer: kang <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 file2
kangdeMacBook-Air:test1 kang$ git log --oneline
ff57efb (HEAD -> master) 第二次提交
c405f76 file1
kangdeMacBook-Air:test1 kang$ git reset HEAD^      不會改變暫存區的檔案
kangdeMacBook-Air:test1 kang$ git log --oneline
c405f76 (HEAD -> master) file1
kangdeMacBook-Air:test1 kang$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    file2

nothing added to commit but untracked files present (use "git add" to track)