Jenkins持续集成 之 git常用命令
git本地仓库命令
git --help
调出git的帮助文档
git +命令 --help
查看某个具体命令的帮助文档
git --version
查看git的版本
git init
在当前目录下,生成一个空的本地仓库(.git)
git add
将文件添加到暂存区
git commit -m "test"
将暂存区里的文件提交到本地仓库
命令显示
git远程仓库命令
git clone--克隆远程仓库的文件
kangdeMacBook-Air:TEST kang$ pwd
/Users/kang/Desktop/TEST
kangdeMacBook-Air:TEST kang$ git clone https://github.com/mingkangzhou/cedarhd.git
Cloning into 'cedarhd'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 18 (delta 3), reused 14 (delta 1), pack-reused 0
Unpacking objects: 100% (18/18), done.
kangdeMacBook-Air:TEST kang$ ls
cedarhd
kangdeMacBook-Air:TEST kang$ ls cedarhd/
test.txt test1.txt test2.txt test3.txt test4.txt
git push--把本地仓库的所有文件推送到远程仓库
kangdeMacBook-Air:cedarhd kang$ touch test5.txt
kangdeMacBook-Air:cedarhd kang$ git add *
kangdeMacBook-Air:cedarhd kang$ git commit -m "add file test5.txt"
[master 6bf6ff1] add file test5.txt
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, 0 insertions(+), 0 deletions(-)
create mode 100644 test5.txt
kangdeMacBook-Air:cedarhd kang$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 270 bytes | 270.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/mingkangzhou/cedarhd.git
efe32ea..6bf6ff1 master -> master
kangdeMacBook-Air:cedarhd kang$
git fetch--拉取远程仓库的变更到本地仓库
kangdeMacBook-Air:cedarhd kang$ ls -al
total 32
drwxr-xr-x 9 kang staff 306 12 1 16:21 .
drwxr-xr-x 4 kang staff 136 12 1 16:21 ..
drwxr-xr-x 14 kang staff 476 12 1 16:21 .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
kangdeMacBook-Air:cedarhd kang$ git fetch
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From https://github.com/mingkangzhou/cedarhd
6bf6ff1..e86dfd0 master -> origin/master
kangdeMacBook-Air:cedarhd kang$ ls -al #此时还没有显示新增的文件
total 32
drwxr-xr-x 9 kang staff 306 12 1 16:21 .
drwxr-xr-x 4 kang staff 136 12 1 16:21 ..
drwxr-xr-x 15 kang staff 510 12 1 16:34 .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
kangdeMacBook-Air:cedarhd kang$
git merge --将远程的变更,合并到本地仓库
kangdeMacBook-Air:cedarhd kang$ git merge
Updating 6bf6ff1..e86dfd0
Fast-forward
test6.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test6.txt
kangdeMacBook-Air:cedarhd kang$ ls -al
total 32
drwxr-xr-x 10 kang staff 340 12 1 16:37 .
drwxr-xr-x 4 kang staff 136 12 1 16:21 ..
drwxr-xr-x 16 kang staff 544 12 1 16:37 .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
转载于:https://blog.51cto.com/12965094/2324706