网站开发实用技术电子版,购物网站名字大全,西宁的网站设计,c2c是什么平台学习目标#xff1a; 在linux 上安装Git 服务器 在windows 上安装 Git 客户端 创建Git仓库#xff0c;git用户 在windows 中获取项目#xff0c;对项目进行增删改查#xff0c;更新到服务器 创建两个分支#xff0c;进行分支修改和代码合并 1. 在linux上安装git服务器 使用…学习目标 在linux 上安装Git 服务器 在windows 上安装 Git 客户端 创建Git仓库git用户 在windows 中获取项目对项目进行增删改查更新到服务器 创建两个分支进行分支修改和代码合并 1. 在linux上安装git服务器 使用指令sudo apt-get install git 安装完成效果 starkubuntu:~$ git --version
git version 2.7.4 2. 安装Git客户端,下载Git for Windows安装完成运行Git Bash 输入指令 $ git --version
git version 2.15.0.windows.13. 服务器端创建Git 仓库 starkubuntu:~/data/git$ mkdir gittest.git
starkubuntu:~/data/git$ git init gittest.git
Initialized empty Git repository in /home/stark/data/git/gittest.git/.git/以为git 默认禁止push代码需要配置 .git/config 文件添加 (push失败后网上查询) [receive]denyCurrentBranch ignore添加git用户和git用户组并且修改权限 #创建用户组
sudo groupadd gituser
#创建用户
sudo useradd gituser -g gituser
sudo passwd gituser
sudo mkdir /home/gituser
sudo chown -R gituser /home/gituser
#修改git仓库权限
sudo chown -R gituser.gituser gittest.git4. 客户端抓取项目进行增删改查 # 下载项目
$ git clone gituser1192.168.195.149:/home/stark/data/git/gittest.git
Cloning into gittest...
gituser1192.168.195.149s password:
warning: You appear to have cloned an empty repository.
$ git init gittest/
Reinitialized existing Git repository in D:/GitTest/gittest/.git/
#创建文件上传
$ echo hellohithello.txt
$ git add hello.txt
$ git commit -m hello
$ git push origin master
#修改文件上传
$ echo hellogit hello.txt
$ git add hello.txt
$ git commit -m modify
$ git push origin master
#在另一处确认修改
$ git pull
#删除文件
$ rm hello.txt
$ git rm hello.txt
$ git commit -m remove
$ git push origin master
#查询日志 关键信息是commit id
$ git log
#回滚到某一版本本地版本
$ git reset –hard commit id在仓库下没有发现上床的文件因为git仓库保存的是快照。在另外一处重新抓取项目可以发现文件已经被上传了 5. 使用Git的分支功能 #添加一个空白文件
$ touch branch.txt
$ git add status
$ git commit -m add file
$ git push origin master
#创建分支
$ git branch testing1
$ git branch testing2
#查看本地分支
$ git branch
#切换到分支进行文件修改push到远程分支
$ git checkout testing1
$ echo testing1 branch.txt
$ git add branch.txt
$ git commit -m testing1
$ git push origin testing1$ git checkout testing2
$ echo testing2 branch.txt
$ git add branch.txt
$ git commit -m testing2
$ git push origin testing2
#查看远程分支
$ git branch -r
#合并分支1上传删除分支
$ git checkout master
$ git merge testing1 # Fast-forward 表示没有冲突
$ git push origin master
$ git push origin --delete testing1
$ git branch -d testing1
#合并分支2解决冲突上传删除分支
$ git merge testing2 #CONFLICT 表示合并出现冲突
#解决冲突后像修改文件一样上传就行 转载于:https://www.cnblogs.com/starktan/p/9315200.html