码迷,mamicode.com
首页 > 其他好文 > 详细

Jenkins持续集成 之 git更改提交

时间:2018-12-02 16:07:56      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:user   one   auth   hat   tag   文件名   can   struct   entity   

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 <kang@kangdeMacBook-Air.local>
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)

git reset --hard HEAD^---版本回滚到上一次提交commit,暂存区跟工作区的文件都会改变

kangdeMacBook-Air:test1 kang$ ls
file1   file2
kangdeMacBook-Air:test1 kang$ git log --oneline
c405f76 (HEAD -> master) file1
kangdeMacBook-Air:test1 kang$ git add file2
kangdeMacBook-Air:test1 kang$ git commit -m "第二次提交"
[master 8265e63] 第二次提交
 Committer: kang <kang@kangdeMacBook-Air.local>
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
8265e63 (HEAD -> master) 第二次提交
c405f76 file1
kangdeMacBook-Air:test1 kang$ ls
file1   file2
kangdeMacBook-Air:test1 kang$ git reset --hard HEAD^
HEAD is now at c405f76 file1
kangdeMacBook-Air:test1 kang$ ls
file1

Jenkins持续集成 之 git更改提交

标签:user   one   auth   hat   tag   文件名   can   struct   entity   

原文地址:http://blog.51cto.com/12965094/2324926

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!