GIT 牛刀小试 (第二发)

一、分支

创建分支:
$ git branch branch-name
切换到某个分支:
$ git checkout branch-name
这两条命令可以简写成:
$ git checkout -b branch-name
合并分支:
$ git merge branch-name (合并到哪个分支就切换到哪个分支执行命令)
删除分支:
$ git branch -d branch-name
解决冲突:如果出现冲突,在执行合并分支命令时系统会给出提醒,要手工完成冲突解决或者调用图形化工具,可以通过 $ git status 去的人是否解决冲突,解决后文件默认进入暂存区,直接提交即;
$ git mergetool
查看分支:
$ git branch [-v][--merge || --no-merged]
推送本地分支到远程:
$ git push origin branch-name

 二、协议

GIT支持使用四种协议来传输数据:本地传输,SSH协议,Git协议,HTTP协议;

本地协议:
$ git clone file:///opt/git/project.git
SSH协议:
$ git clone ssh://user@server/project.git
Git协议:
$ git clone git://github.com/name/project.git
HTTP/S协议:
$ git clone http://xxx.com/project.git
 

搭建服务器的内容不再记述,因为技术比较复杂并且使用的很少,搭建的时候请看《第一发》推荐的廖雪峰教程或者proGit;

附:
git config --global user.name "kiscall"
git config --global user.password "kiscall1024@gmail.com"
git init
git status
git add test.txt
git commit -m "wrote a test file"

git diff test.txt
git diff
git diff -cached
git diff HEAD
git diff HEAD --test.txt
第一个命令我目前的理解应该是和工作区和本地仓库的区别

git log
git log --pretty=oneline
git reset --hard HEAD^
git reset --hard 版本号
git reflog

git checkout -- test.txt
git reset HEAD test.txt

git rm test.txt
git commit -m "remove test.txt"
or
git checkout -- test.txt

ssh-keygen -t rsa -C "kiscall1024@gmail.com"
git remote add origin git@github.com:kiscall/learngit.git
git push -u origin master  (git push origin mater)
git clone git@github.com:kiscall/learngit.git
git pull

git branch dev
git checkout dev
git branch
git merge dev
git branch -d dev
git branch -D dev

git merge --no-ff -, "merge with no-ff" dev
git log --graph --pretty=oneline --abbrev-commit

git stash
git stash list
git stash apply 版本号
git stash pop
git stash drop

git remote
git remote -v
git branch --set-upstream dev origin/dev
git checkout -b dev origin/dev

git tag
git tag v1.0
git tag v0.9 版本号
git show v1.0
git tag -d v0.1
git push origin:refs/tags/v0.9
git push origin v1.0
git push origin --tags

git config --global color.ui true
.gitignore文件:
#
#
git config --global alias.co checkout
原文地址:https://www.cnblogs.com/kiscall/p/4701477.html