git安装及使用

git安装及使用官网
可参考菜鸟教程git
git 安装
 
windows 安装
下载地址:
32
https://github.com/git-for-windows/git/releases/download/v2.16.1.windows.1/Git-2.16.1-32-bit.exe
64
https://github.com/git-for-windows/git/releases/download/v2.16.1.windows.1/Git-2.16.1-64-bit.exe
 
linux(centos) 安装
    yum install git-core
 
 
git 使用
 
1、创建新仓库
 
mkdir -p  /data/gittest
cd /data/gittest
git init
 
2、克隆仓库
 
克隆本地仓库的克隆版本
git clone /path/to/repository
 
克隆远程仓库克隆版本
git clone username@host:/path/to/repository
 
3、添加和提交
 
更改添加到缓存区
    添加单个文件
    git add <filename>
    添加多个文件
    git add *
     
提交更改动
git commit -m "代码提交信息"
 
4、推送改动到远程仓库
git push origin master
(可以把 master 换成你想要推送的任何分支)
 
 
将你的仓库连接到某个远程服务器
git remote add origin <server>
 
5、分支
 
创建分支feature_x 并切换过去
git checkout -b feature_x
 
切换到主分支
git checkout master
 
删除分支
git branch -d feature_x
 
推送分支到远程
git push origin <branch>
 
6、更新与合并
 
更新本地分支至最新
git pull
 
合并其他分支到当前分支
git merge  <branch>
 
比较差异
git diff <source_branch> <target_branch>
 
7、标签
创建一个叫做 1.0.0 的标签:
git tag 1.0.0 1b2e1d63ff
(1b2e1d63ff 是你想要标记的提交 ID 的前 10 位字符。可以使用下列命令获取提交 ID:)
 
git log

posted on 2020-03-23 15:24  科比08  阅读(140)  评论(0编辑  收藏  举报

导航