1、介绍
Git是一个免费的、开源的分布式版本控制系统,可以快速高效的处理从小型到大型的各种项目。
Git易于学习,占地面积小,性能机快,它具有廉价的本地库,方便的暂存区域和多个工作流分支等特性。据说性能优于Subversion、CVS、Perforce和ClearCase等版本控制工具。
官网:https://git-scm.com
1.3 版本控制工具
- 集中式版本控制工具
CVS、SVN(Subversion)、VSS…
集中化的版本控制系统诸如CVS、SVN等,都有一个单一的集中管理的服务器,保存所有文件的修订版本,而协同工作的人们都通过客户端连接到这台服务器,取出最新的文件或着提交更新。多年以来,这已经为版本控制系统的标准做法。
这种做法带来了许多好处,每个人都可以在一定程度上看到项目中的其他人正在做些什么,而管理员也可以轻松掌控每个开发者的权限,并且管理一个集中化的版本控制系统,要比在各个客户端上维护本地数据库来的轻松容易。
缺点是,中央服务器单点故障。如果服务器宕机一小时,那么在这一小时内,谁都无法提交更新,也无法协同工作。
- 分布式版本控制工具
Git、Mercurial、Bazaar、Darcs…
像Git这种分布式版本控制工具,客户端提取的不是最新版本的文件快照,而是把代码仓库完整地镜像下来(本地库)。这样任何一处协同工作用的文件发生故障,时候都可以用其他客户端的本地仓库进行恢复。因为每个客户端的每一次文件提取操作,实际上都是一次对这整个文件仓库的完整备份。
分布式的版本空hi系统出现之后,解决了集中式版本控制系统的缺陷:
1、服务器断网的情况下,也可以进行开发(因为版本控制是在本地进行的)
2、每个客户端保存的也都是完整的项目(包含历史记录,更加安全)
1.4 Git简史
1.5 Git工作机制
1.6 Git和代码托管中心
代码托管中心是基于网络服务器的远程代码仓库,一般我们简单称为远程库。
- 局域网
- GitLab
- 互联网
- GitHub(外网)
- Gitee码云(国内网站)
2、Git安装
官网地址:https://git-csm.com
最好安装到一个没有空格的目录中:
选择编辑器:
选择默认的库:通常默认库为master
选择后台客户端的连接协议:
选择换行符:windows是回车换行,Linux是换行。下面选择的是有git自己根据系统进行转换处理。
选择使用的终端类型(默认即可):
选择默认的拉取类型:从远程库拉取代码到本地库,当出现冲突时采用何种方式合并代码?默认即可。
选择凭据管理器:登录过一次之后,下次就不用再重新登录了。默认即可。
选择文件管理机制:使用缓存文件管理机制。默认即可。
是否使用实验性功能:否。
验证是否成功:在桌面右单击有如下菜单,表示成功。
GUI方式:
Bash方式:推荐使用方式
3、Git常用命令
3.1 设置用户签名
1)基本语法
git config --global user.name 用户名
git config --global user.emal 邮箱
设置完后,在当前系统账号的家目录下就能看到如下文件和信息:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-B0WMbjJe-1675739087739)(C:\Users\dangqy\AppData\Roaming\Typora\typora-user-images\image-20220803215254340.png)]
说明:
签名的作用是用来区分不同用户的身份。通过用户签名可以确定每一个版本的提交者信息。Git首次安装后必须设置以下用户签名,否则无法提交代码。
注意:这里设置的用户签名和将来登录GitHub(或其他代码托管中心)的账号是没有任何关系的。
3.2 初始化本地库
1)基本语法
git init
2)案例实操
比如有一个项目叫git-demo在E:\logs\git-demo目录下,那么我们可以进入此目录后,鼠标右单击“Git Bash Here”,即可打开git操作窗口,然后在里面输入git init初始化即可:
Git Bash中用的命令,是Linux中通用的命令。
3.3 查看本地库状态
3.3.1 status:查看状态
# git status查看状态:首次使用会显示如下内容
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git status
On branch master # 默认分支的名字
No commits yet # 没有要提交的内容
nothing to commit (create/copy files and use "git add" to track)
3.3.2 add:新建文件,添加到暂存区
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ vi hello.txt
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ cat hello.txt
hello
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ ll
total 1
-rw-r--r-- 1 dangqy 197121 6 Aug 3 22:06 hello.txt
# 当前新创建文件后,文件处在工作区中。
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello.txt
nothing added to commit but untracked files present (use "git add" to track)
# 执行添加后,文件进入暂存区:“LF will be replaced by CRLF”就是git自动给转换的换行符提示信息(安装时所选)
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git add hello.txt
warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: hello.txt
# 将hello.txt从暂存区删除
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git rm --cached hello.txt
rm 'hello.txt'
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello.txt
nothing added to commit but untracked files present (use "git add" to track)
3.5 commit:提交本地库
语法:git commit -m “提交的说明信息” 文件名
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git commit -m "首次提交测试" hello.txt
warning: in the working copy of 'hello.txt', LF will be replaced by CRLF the next time Git touches it
[master (root-commit) a3c27a5] 首次提交测试
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean
# 查看日志信息
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git reflog
a3c27a5 (HEAD -> master) HEAD@{0}: commit (initial): 首次提交测试
# 查看详细日志信息
dangqy@DANGQY MINGW64 /e/logs/git-demo (master)
$ git log
commit a3c27a5f8154df8e99efc5eac2b1d8c98ba66a1c (HEAD -> master)
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Wed Aug 3 22:20:07 2022 +0800
首次提交测试
3.6 修改文件
以新的git库为例:
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git commit -m "首次使用,测试,一会删掉" test.txt
error: pathspec 'test.txt' did not match any file(s) known to git
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git add test.txt
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git commit -m "首次使用,测试,一会删掉" test.txt
[master 6bd22597] 首次使用,测试,一会删掉
1 file changed, 1 insertion(+)
create mode 100644 test.txt
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
# 可以直接用vi进行修改内容并保存
$ vi test.txt
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
# 通过查看状态,可以发现已被修改的文件
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: test.txt
no changes added to commit (use "git add" and/or "git commit -a")
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git add test.txt test.txt
warning: in the working copy of 'test.txt', LF will be replaced by CRLF the next time Git touches it
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ 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 restore --staged <file>..." to unstage)
modified: test.txt
# 若是这是修改了一行文件,但git提交时,会显示一行新增,一行删除,这是因为git中的操作是先删除这一行,然后再新增修改的这一行内容
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git commit -m "二次修改测试" test.txt
warning: in the working copy of 'test.txt', LF will be replaced by CRLF the next time Git touches it
[master 0109650f] 二次修改测试
1 file changed, 2 insertions(+), 1 deletion(-)
# 查看版本信息,修改几次,这里会查到几次版本提交信息
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git reflog
7b8beef7 (HEAD -> master) HEAD@{0}: commit: 3次修改
0109650f HEAD@{1}: commit: 二次修改测试
6bd22597 HEAD@{2}: commit: 首次使用,测试,一会删掉
e6b782bd (origin/master, origin/dangqy-test, origin/HEAD) HEAD@{3}: clone: from http://152.136.177.212:3000/Supp/eip.git
3.7 reset --hard:版本穿梭(版本回退)
# 查看详细版本号
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git log
commit 7b8beef72ae11a6540235e427b87b316d7cfcfb7 (HEAD -> master)
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Thu Sep 29 17:04:07 2022 +0800
3次修改
commit 0109650fa16f806dbd0569e8aa95023b2ebe799b
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Thu Sep 29 16:59:46 2022 +0800
二次修改测试
commit 6bd22597fa1d26a30c5038f45ece2997ef1881ca
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Thu Sep 29 16:53:35 2022 +0800
首次使用,测试,一会删掉
commit e6b782bd692ed11572729ffd488a870c11dcd7c4 (origin/master, origin/dangqy-test, origin/HEAD)
Author: xieyunhui <xiexuehua@dhcc.com.cn>
Date: Thu Sep 29 16:07:02 2022 +0800
:...skipping...
commit 7b8beef72ae11a6540235e427b87b316d7cfcfb7 (HEAD -> master)
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Thu Sep 29 17:04:07 2022 +0800
3次修改
commit 0109650fa16f806dbd0569e8aa95023b2ebe799b
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Thu Sep 29 16:59:46 2022 +0800
二次修改测试
commit 6bd22597fa1d26a30c5038f45ece2997ef1881ca
Author: dangqingyao <dangqingyao@dhcc.com.cn>
Date: Thu Sep 29 16:53:35 2022 +0800
首次使用,测试,一会删掉
commit e6b782bd692ed11572729ffd488a870c11dcd7c4 (origin/master, origin/dangqy-test, origin/HEAD)
Author: xieyunhui <xiexuehua@dhcc.com.cn>
Date: Thu Sep 29 16:07:02 2022 +0800
优化:租户图片更新,更新当前租户的租户信息
# 查看简单版本号
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git reflog
7b8beef7 (HEAD -> master) HEAD@{0}: commit: 3次修改
0109650f HEAD@{1}: commit: 二次修改测试
6bd22597 HEAD@{2}: commit: 首次使用,测试,一会删掉
e6b782bd (origin/master, origin/dangqy-test, origin/HEAD) HEAD@{3}: clone: from
# 穿越(回退)到制定版本
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git reset --hard 0109650f
HEAD is now at 0109650f 二次修改测试
# 查看版本信息
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ git reflog
0109650f (HEAD -> master) HEAD@{0}: reset: moving to 0109650f
7b8beef7 HEAD@{1}: commit: 3次修改
0109650f (HEAD -> master) HEAD@{2}: commit: 二次修改测试
6bd22597 HEAD@{3}: commit: 首次使用,测试,一会删掉
e6b782bd (origin/master, origin/dangqy-test, origin/HEAD) HEAD@{4}: clone: from http://152.136.177.212:3000/Supp/eip.git
# 内容已还原
dangqy@DANGQY MINGW64 /e/2012-supporter/CP6.2/eip (master)
$ cat test.txt
1.0
1.1
打开.git下的HEAD文件,可以看到当前实在哪个分支上:
打开.git\refs\heads\master,可以看到当前所在分支的位置(或叫称版本号):
上图中2个文件的版本号是对应的。
Git版本切换,底层就是移动HEAD指针。
3.8 clone:下载代码
下载主线
clone操作是当本地没有代码时,从Git仓库下载代码。
# 下载最新代码
$ sudo git clone https://github.com/pinpoint-apm/pinpoint.git
下载分支
# 下载指定标签代码
$ sudo git clone --branch v2.4.2 https://github.com/pinpoint-apm/pinpoint.git
3.9 pull:更新、下载代码
pull操作是当本地已经存在版本代码时,从Git仓库更新代码并合并。
# 更新代码
$ sudo git pull https://github.com/pinpoint-apm/pinpoint.git
3.10 更换远程Git仓库地址
# 更换远程Git仓库地址:origin为默认名称,若本地做过修改,请使用修改后的名称
$ git remote set-url origin https://github.com/pinpoint-apm/pinpoint.git
3.11 创建本地库+分支
# 初始化本地库:git init test
$ sudo git init test
# 创建分支:git init -b <分支名称>
$ sudo git init -b dev
# 查看分支情况:如果分支中没有任何文件,此操作将无返回信息。当有多个分支时,前面带*号的就是当前分支。
$ sudo git branch
# 在现有版本库创建分支:git branch <分支名称>
$ sudo git branch cs
# 修改分支名称:git branch -m <原分支名称> <新分支名称>
$ sudo git branch -m cs abc
# 删除分支:git branch -d <分支名称>
# -d:用于删除已合并过的分支
# -D:强制删除分支
$ sudo git branch -d abc
# 切换到分支:git checkout <分支名称>
$ sudo git checkout dev
# 创建分支并切换到新分支:git checkout -b <分支名称>
$ sudo git checkout -b test
# 合并分支:git merge <被合并的分支名称>
# 假如当前在master分支下,当运行下列命令后,会将dev合并到当前的master分支中
$ sudo git merge dev
4、Git分支操作
这张图可以从右往左看:
4.1 什么是分支
在版本控制过中,同时推进多个任务,为每个任务,我们就可以创建每个人物的单独分支。使用分支意味着程序员可以把自己的工作从开发主线上分离出来,开发自己分支的时候,不会影响主线分支的运行。对于初学者而言,分支可以简单理解为副本,一个分支就是一个单独的副本。
4.2 分支的好处
同时并行推进多个功能开发,提搞开发效率。
各个分支在开发过程中,如果某一个分支开发失败,不会对其他分支有任何影响。失败的分支删除重新开发即可。
4.3 分支的操作
命令 | 作用 |
---|---|
git branch 分支名 | 创建分支 |
git branch -v | 查看分支 |
git checkout 分支名 | 切换分支 |
git merge 分支名 | 将制定的分支合并到当前分支上 |
4.3.1 查看分支
dangqy@DANGQY MINGW64 /e/git-demo
$ git init
Initialized empty Git repository in E:/git-demo/.git/
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ vi test.txt
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git add test.txt
warning: in the working copy of 'test.txt', LF will be replaced by CRLF the next time Git touches it
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: test.txt
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git commit -m "1.1" test.txt
warning: in the working copy of 'test.txt', LF will be replaced by CRLF the next time Git touches it
[master (root-commit) 2e9493b] 1.1
1 file changed, 1 insertion(+)
create mode 100644 test.txt
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git branch -v
* master 2e9493b 1.1
4.3.2 创建分支
# 创建新分支
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git branch hot-fix
# 无任何区别
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ ls
test.txt
# 查看分支
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git branch -v
hot-fix 2e9493b 1.1
* master 2e9493b 1.1
4.3.3 切换分支
# 切换分支
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'
# 查看分支
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git branch -v
* hot-fix 2e9493b 1.1
master 2e9493b 1.1
# 在hot-fix分支上修改文件
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ vi test.txt
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ cat test.txt
1.1
1.2-hot-fix
# 未提交前查看日志情况:竟然同时是在2个分支下
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git reflog
2e9493b (HEAD -> hot-fix, master) HEAD@{0}: checkout: moving from master to hot-fix
2e9493b (HEAD -> hot-fix, master) HEAD@{1}: checkout: moving from hot-fix to master
2e9493b (HEAD -> hot-fix, master) HEAD@{2}: checkout: moving from master to hot-fix
2e9493b (HEAD -> hot-fix, master) HEAD@{3}: checkout: moving from hot-fix to master
2e9493b (HEAD -> hot-fix, master) HEAD@{4}: checkout: moving from master to hot-fix
2e9493b (HEAD -> hot-fix, master) HEAD@{5}: commit (initial): 1.1
# 未提交前,切换称master分支,查看文件内容:内容竟然是hot-fix修改后的
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git checkout master
Switched to branch 'master'
M test.txt
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ cat test.txt
1.1
1.2-hot-fix
# 未提交前,再切换回hot-fix分支,查看文件内容:内容依然是hot-fix修改后的
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'
M test.txt
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ cat test.txt
1.1
1.2-hot-fix
# 将修改的文件提交之后,内容就会发生变化
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git commit -m "hot-fix commit 1" test.txt
warning: in the working copy of 'test.txt', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'test.txt', LF will be replaced by CRLF the next time Git touches it
[hot-fix ec54a87] hot-fix commit 1
1 file changed, 1 insertion(+)
# 分支正常
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git reflog
ec54a87 (HEAD -> hot-fix) HEAD@{0}: commit: hot-fix commit 1
2e9493b (master) HEAD@{1}: checkout: moving from master to hot-fix
2e9493b (master) HEAD@{2}: checkout: moving from hot-fix to master
2e9493b (master) HEAD@{3}: checkout: moving from master to hot-fix
2e9493b (master) HEAD@{4}: checkout: moving from hot-fix to master
2e9493b (master) HEAD@{5}: checkout: moving from master to hot-fix
2e9493b (master) HEAD@{6}: commit (initial): 1.1
# hot-fix修改后的文件正常
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ cat test.txt
1.1
1.2-hot-fix
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git checkout master
Switched to branch 'master'
# 修改后的文件在hot-fix提交后,切换称master分支后,内容则显示正常(master本该显示的内容)
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ cat test.txt
1.1
4.3.4 合并分支
git merge 分支名:将指定分支内容,合并到当前分支上。
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git merge hot-fix
Updating 2e9493b..ec54a87
Fast-forward
test.txt | 1 +
1 file changed, 1 insertion(+)
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ cat test.txt
1.1
1.2-hot-fix
4.3.5 合并分支(冲突合并)
# 修改master上的文件,并提交
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ cat test.txt
1.1
1.2-hot-fix
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ vi test.txt
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ cat test.txt
1.1 master1
1.2-hot-fix
# 一般可直接commit,但有时会出问题,所以标准步骤是先git add...,然后再git commit...
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git commit -m "master modify 1" test.txt
[master 7966207] master modify 1
1 file changed, 2 insertions(+), 1 deletion(-)
# 切换成hot-fix分支,并修改同一个文件,并提交
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ vi test.txt
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git commit -m "hot-fix modify" test.txt
[hot-fix a3ba083] hot-fix modify
1 file changed, 1 insertion(+)
# 切换回master
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git checkout master
Switched to branch 'master'
# 执行合并命令后,提示冲突
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ git merge hot-fix
Auto-merging test.txt
CONFLICT (content): Merge conflict in test.txt
Automatic merge failed; fix conflicts and then commit the result.
# 查看冲突文件:出现冲突后,就只能手动修改
dangqy@DANGQY MINGW64 /e/git-demo (master|MERGING)
$ cat test.txt
1.1 master1
1.2-hot-fix
<<<<<<< HEAD
=======
hotfox
>>>>>>> hot-fix
# 手动修改后
dangqy@DANGQY MINGW64 /e/git-demo (master|MERGING)
$ vi test.txt
dangqy@DANGQY MINGW64 /e/git-demo (master|MERGING)
$ cat test.txt
1.1 master1
1.2-hot-fix
hotfox
# 添加到暂存区
dangqy@DANGQY MINGW64 /e/git-demo (master|MERGING)
$ git add test.txt
# 然后提交:这里提交不能写文件名
dangqy@DANGQY MINGW64 /e/git-demo (master|MERGING)
$ git commit -m "合并冲突"
[master 1b674a3] 合并冲突
dangqy@DANGQY MINGW64 /e/git-demo (master)
$ cat test.txt
1.1 master1
1.2-hot-fix
hotfox
# 分支从master上更新到本地
# 完整语法git origin master:分支名
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git origin master
git: 'origin' is not a git command. See 'git --help'.
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git pull origin master
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 14 (delta 6), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (14/14), 891 bytes | 0 bytes/s, done.
From http://IP:PORT/????
* branch master -> FETCH_HEAD
e6b782bd..acd7909c master -> origin/master
Updating e6b782bd..acd7909c
Fast-forward
.../com/supporter/prj/eip/app_setting/service/GeneralParamService.java | 1 -
1 file changed, 1 deletion(-)
# 查看远程主机信息
dangqy@DANGQY MINGW64 /e/git-demo (hot-fix)
$ git remote -v
origin http://IP:PORT/????/??.git (fetch)
origin http://IP:PORT/????/??.git (push)
总结:
1、将指定远程分支仓库的代码更新到本地分支(当前仓库):用git pull origin master
2、将当前分支仓库中的代码修改,提交到远程分支仓库:git push origin master
注:master为分支名称。