git經常使用總結

git 基本配置

安裝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經常使用操做

git 提交代碼

# 提交文件到暫存區
git add .   #添加全部更改到文件
git add test.py  # 添加指定文件 

# 查看狀態
git status

#提交到本地代碼庫
git commit -m "提交說明"

# push到遠程代碼庫
git push -u origin master 

# 更新代碼,必須在git項目目錄中
git pull

 

git 分支操做

[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指定的tag

git clone --depth=1 --branch=指定tag git@地址
--depth    depth用於指定克隆深度,爲1即表示只克隆最近一次commit.
--branch   拉取指定tag
相關文章
相關標籤/搜索