项目管理工具git的安装与使用

行云流水
2022-03-16 / 0 评论 / 432 阅读 / 正在检测是否收录...

l0to8r9e.png

前言

git 2015年诞生,自此以后日臻成熟,逐渐发展壮大!在保证你快速高效管理你的代码同时,又保证自己简单易用,这么久以来依然坚持自己的目标,他的速度飞快,非常适合管理大型项目。

安装

最新版本编译安装
#安装支持软件
yum install autoconf  gcc   zlib  zlib-devel
#下载源码
wget https://github.com/git/git/archive/v2.28.0.tar.gz
#编译并配置
tar xvf v2.28.0.tar.gz
cd git-2.28.0/
make configure
./configure --prefix=/usr/local/git
 make && make install
配置环境变量
mv /usr/bin/git /usr/bin/git.bak
#编辑文件
vim /etc/profile
GIT_HOME=/usr/local/git
PATH=$PATH:$GIT_HOME/bin   #53行
验证
source /etc/profile
git --version

基本用法

#获取项目
git clone git@gitlab.com:myproject97/sys.git

#更新分支
git pull

#查看当前分支
git status

#更新
git add .
git commit -m "更新"
git push

#查看所有分支
git branch
#远程
git branch -r  

版本管理

#创建版本
git tag -a v1.0.1 -m "1.0版本,2020-03-02上线"

#查看版本记录
git tag 

#推送
git push origin v1.0.1

分支管理策略

主分支master/main

开发分支develop

#创建开发分支
git checkout -b develop master

#发布develop
git checkout master
git merge --no-ff develop

修补bug分支

#创建一个修补bug分支
git checkout -b fixbug-0.1 master

#修补完成后,合并到master
git checkout master
git merge --no-ff fixbug-0.1
git tag -a 0.1.1

#合并到develop分支
git checkout develop
git merge --no-ff fixbug-0.1

#删除"修补bug分支"
git branch -d fixbug-0.1

#查看远程分支
git branch -r 
git push origin --delete  develop

常见问题

保存空目录

cat <<EOF> .gitignore
*
!.gitignore
EOF

乱码问题

git status乱码

解决办法:

git config --global core.quotePath false

参考

Learning Git Branching

Git分支管理策略

评论 (0)

取消
只有登录/注册用户才可评论