Jenkins持續集成 之 git文件狀態
阿新 • • 發佈:2018-12-02
his cbo use log roc mac text 暫存 Staff 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文件狀態