安装git yum -y install git git全局配置 git config --global user.name "lsc" #配置git使用用户 git config --global user.email "243541755@qq.com" #配置git使用邮箱 git config --global color.ui true #语法高亮 git config --list # 查看全局配置
# 提交文件到暂存区 git add . #添加全部更改到文件 git add test.py # 添加指定文件 # 查看状态 git status #提交到本地代码库 git commit -m "提交说明" # push到远程代码库 git push -u origin master # 更新代码,必须在git项目目录中 git pull
[root@gitlab git_data]# git branch linux //建立分支 * master [root@gitlab git_data]# git checkout linux //切换分支
[root@gitlab git_data]# git branch -vv //查看当前分支,当前分支前面有*号 master 0952c24 [origin/master: behind 4] add port forwading for game server * stage b1ae9f8 [origin/stage] Add new file
git clone --depth=1 --branch=指定tag git@地址 --depth depth用于指定克隆深度,为1即表示只克隆最近一次commit. --branch 拉取指定tag