git自用笔记

同步远程库:git clone xxx.git [filename]

 

git ls-files: 查看已经添加进暂存区的文件。

在commit前修改一个文件后(假设名为:xxx.file),想撤销时,

1:如果还未git add,可以利用git checkout -- xxx.file,从暂存区拿出修改前的xxx.file。

2:如果已经git add,那么暂存区已经是修改过了,直接利用git reset HEAD xxx.file返回上一次comiit的状态,再执行git checkout

 

查看远程主机:git remote show <remote>

添加远程库:git remote add <remote> xxx.git 

更新远程库:git fetch <remote>

上传本地到远程:git push -u <remote> <branch in remote>:[branch],其中-u参数代表关联本地和远程分支,简化后git pull命令。

下拉远程到本地:git pull <remote> <branch in remote>:[branch]

 

创建分支:git branch <branch>

创建并切换分支:git checkout -b <banch> [remote/branch]

切换分支:git checkout <branch>

查看分支:git branch或者git branch -a,-a包含remote的分支

删除分支:git branch -d <branch> ,-d替换成-D可以强制删除分支

合并分支:git merge <branch>,采用Fast-forward或者git merge --no-ff <branch> ,-m "xxxxx"参数可以把后的分支commit

 

查看贮藏区:git stash list

存入贮藏区:git stash push

取出贮藏区:git stash pop

 

添加标签:git tag <tag name> <commit id>

删除标签:git tag -d <tagmame>

展示特定标签:git show <tagname>

 

posted @ 2017-02-07 15:06  Kevin_Hwang  阅读(128)  评论(0编辑  收藏  举报