Jenkins持续集成 之 git文件状态

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jenkins持续集成 之 git文件状态相关的知识,希望对你有一定的参考价值。

Jenkins持续集成 之 git文件状态

git 文件状态图

技术分享图片

git文件状态展示

kangdeMacBook-Air:cedarhd kang$ git status       #git文件状态查询
On branch master
Your branch is up to date with ‘origin/master‘.

nothing to commit, working tree clean

kangdeMacBook-Air:cedarhd kang$ touch test8.txt  #新建文件
kangdeMacBook-Air:cedarhd kang$ git status
On branch master
Your branch is up to date with ‘origin/master‘.

Untracked files:       #Untracked 新建文件状态
    (use "git add <file>..." to include in what will be committed)

    test8.txt

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

kangdeMacBook-Air:cedarhd kang$ git add test8.txt  #提交到暂存区
kangdeMacBook-Air:cedarhd kang$ git status
On branch master
Your branch is up to date with ‘origin/master‘.

Changes to be committed:         #已经到了stage状态
    (use "git reset HEAD <file>..." to unstage)

    new file:   test8.txt

kangdeMacBook-Air:cedarhd kang$ git commit -m "test8.txt"  #提交到本地工作区
[master a6defd1] test8.txt
 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, 0 insertions(+), 0 deletions(-) 
 create mode 100644 test8.txt
kangdeMacBook-Air:cedarhd kang$ git status        #unmodified 没有修改状态
On branch master
Your branch is ahead of ‘origin/master‘ by 1 commit.
    (use "git push" to publish your local commits)

nothing to commit, working tree clean

kangdeMacBook-Air:cedarhd kang$ git rm --cache test8.txt   #从缓存区删除test8.txt
rm ‘test8.txt‘
kangdeMacBook-Air:cedarhd kang$ git status
On branch master
Your branch is ahead of ‘origin/master‘ by 1 commit.
    (use "git push" to publish your local commits)

Changes to be committed:
    (use "git reset HEAD <file>..." to unstage)

    deleted:    test8.txt

Untracked files:           #已返回Untracked文件
    (use "git add <file>..." to include in what will be committed)

    test8.txt

git checkout还原已删除的文件

kangdeMacBook-Air:cedarhd kang$ git add test8.txt    #提交到暂存区
kangdeMacBook-Air:cedarhd kang$ git commit -m "test8.txt"     #提交到工作 区
On branch master
Your branch is ahead of ‘origin/master‘ by 1 commit.
    (use "git push" to publish your local commits)

nothing to commit, working tree clean
kangdeMacBook-Air:cedarhd kang$ rm -f test8.txt      #删除本地文件
kangdeMacBook-Air:cedarhd kang$ ls -al
total 32
drwxr-xr-x  11 kang  staff  374 12  1 23:15 .
drwxr-xr-x   5 kang  staff  170 12  1 16:48 ..
drwxr-xr-x  16 kang  staff  544 12  1 23:15 .git
-rw-r--r--   1 kang  staff    3 12  1 16:18 test.txt
-rw-r--r--   1 kang  staff   23 12  1 16:18 test1.txt
-rw-r--r--   1 kang  staff    0 12  1 16:18 test2.txt
-rw-r--r--   1 kang  staff    6 12  1 16:18 test3.txt
-rw-r--r--   1 kang  staff   17 12  1 16:18 test4.txt
-rw-r--r--   1 kang  staff    0 12  1 16:21 test5.txt
-rw-r--r--   1 kang  staff    0 12  1 16:37 test6.txt
-rw-r--r--   1 kang  staff    0 12  1 22:43 test7.txt
kangdeMacBook-Air:cedarhd kang$ git checkout master test8.txt  #通过工作区还原文件
kangdeMacBook-Air:cedarhd kang$ ls -al
total 32
drwxr-xr-x  12 kang  staff  408 12  1 23:15 .
drwxr-xr-x   5 kang  staff  170 12  1 16:48 ..
drwxr-xr-x  16 kang  staff  544 12  1 23:15 .git
-rw-r--r--   1 kang  staff    3 12  1 16:18 test.txt
-rw-r--r--   1 kang  staff   23 12  1 16:18 test1.txt
-rw-r--r--   1 kang  staff    0 12  1 16:18 test2.txt
-rw-r--r--   1 kang  staff    6 12  1 16:18 test3.txt
-rw-r--r--   1 kang  staff   17 12  1 16:18 test4.txt
-rw-r--r--   1 kang  staff    0 12  1 16:21 test5.txt
-rw-r--r--   1 kang  staff    0 12  1 16:37 test6.txt
-rw-r--r--   1 kang  staff    0 12  1 22:43 test7.txt
-rw-r--r--   1 kang  staff    0 12  1 23:15 test8.txt

以上是关于Jenkins持续集成 之 git文件状态的主要内容,如果未能解决你的问题,请参考以下文章

Jenkins 持续集成平台构建之通过git提交代码

Jenkins持续集成 之 git更改提交

Jenkins持续集成 之 git的 .gitignore文件

Gitlab+jenkins持续集成+自动化部署

Jenkins持续集成 之 git客户端安装

Jenkins持续集成 之 git分支