简单的git使用说明

git使用说明:
1. 设置git用户名和邮箱信息
git config --global user.name "name"
git config --global user.email "name@xxx.com"

2. 建立本地仓库
git init
git add .
git commit

3. 查看log和diff
git diff -cached
git diff
git status
git log

4. clone git
git clone ssh://name@xx.xx.xx.xx/test

5. 管理远程仓库
git remote add origin ssh://name@xx.xx.xx.xx/test
git push origin master
git remote -v
git remote
git remote rm origin
git remote rename

6. 版本管理
git add file_name
git commit
git reset --soft 只撤销commit,保留working tree和index file。
git reset --hard 撤销commit、index file和working tree,即撤销销毁最近一次的commit
git reset --mixed 撤销commit和index file,保留working tree
git reset和git reset --mixed完全一样
git reset -- 用于删除登记在index file里的某个文件。
git reflog -- 看以前所有的log
git reset --hard a745d31b9c0017bf277c8dd2961b180f6d75f617 -- 到commit号a745处

7. 分支管理
git branch branch_name
git branch -- list branch
git branch -d branch_name -- delete a merged branch
git branch -D branch_name -- delete a branch
git checkout branch_name -- switch to branch
git checkout master -- switch to master
git merge branch_name
git tag V3 5b888 //以后可以用V3来代替复杂的名称(5b888…)
git show V3
git branch stable V3 //建立一个基于V3的分支

8. 建立bare仓库
现在test目录下建立仓库
git init
从仓库建立bare仓库
git clone --bare test test.git
bare仓库可以push和pull

实例:
git clone --bare test test.git
git clone ssh://name@xx.xx.xx.xx/test/xxx.git
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值