Git基本用法(上)

原创
2015/05/12 21:12
阅读数 231

1.Git 配置

git config --global user.name "qwop"

git config --global user.email "qwop@live.cn"

cat ~/.gitconfig

2. 获得一个仓库

git clone http://git.shiyanlou.com/shiyanlou/gitproject

git clone http://github.com/shiyanlou/gitproject.git



3 初始化一个仓库

mkdir project

echo 'test content' > project/testfile.txt

cd project

git init


4 正常的工作流程

cd project

touch file1 file2 file3

echo 'testcontent1' > file1

echo 'testcontent2' > file2

echo 'testcontent3' > file3

git add file1 file2 file3


git diff --cached

git status

git commit

git commit -a


5 分支与合并

git branch experimental

git branch

git checkout experimental

git commit -a

git checkout master

git merge experimental

git branch -d experimental

#强制删除

git branch -D crazy-idea


#解决冲突

git add file.txt

git commit


#撤销一个冲突

git reset --hard HEAD

git reset --hard ORIG_HEAD



git config 配置

git clone 复制仓库

git init 初始化仓库

git add 添加更新内容到索引中

git diff 比较内容

git status 获取当前状态

git commit 提交

git branch 分支操作

git checkout 切换分支

git reset 恢复版本

git log 查看日志






展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部