git基础(常用命令)

1`    git remote        列出远程库

       git remote add origin git@github.com:michaelliao/learngit.git        添加远程库

2`    git clone git@github.com:michaelliao/learngit.git        克隆远程库

克隆之后只需要 git branch branchname 然后在 git pull origin branchname 

3`    git branch        列出当前分支

       git branch -a        列出当前所有分支和远程分支

       git branch -r        列出远程分支

       git branch newbranch2        创建一个新的本地分支,需要注意,此处只是创建分支,不进行分支切换,例如:

        #git branch 

        #git branch

        * master

       newbranch

        newbranch2

        当前的分支依然是master,不进行切换。

 

        git branch -m | -M oldbranch newbranch 重命名分支,如果newbranch名字分支已经存在,则需要使用-M强制重命名,否则,使用-m进行重命名。

 

       git branch -d | -D branchname 删除branchname分支

 

       git branch -d -r branchname 删除远程branchname分支

4`    git checkout branchName        切换到新分支

        git checkout -b branchName         创建切换到新分支 在此之前最好git flow init

git checkout . 删除当前分支下所有更新并恢复到原始

5`    git stash        将当前分支工作区内容保存在暂存区 如果你有些东西没完成还想pull代码,那就用这个东西

git stash pop 将暂存区最后一次保存内容恢复到当前所在分支

git stash list  查看暂存区保存内容

git stash stash@{1}  恢复此次备份到当前所在分支

     

6`   git diff 检测不同

7`   git add . 提交所有的

8`   git reset support/yuicompressor-2.4.8.jar 重置你不想提交的

9`   git flow feature start tableSet 在当前分支创建特性 

git flow feature publish

10`   git rebase origin develop 不同分支进行对比,检测

11`   git checkout -f src/Swordfish/Site/Action/Login.php 放弃修改,不用老 reset

12`   git fetch -p  取回远程的tag/分支

13`  gcm 切到master

14`  在hotfix打完后需要在master/develop上都pull/push和push --tags(tags是全局的,不分那个分支)一下

15`  git branch --set-upstream-to=origin/develop   设置当前分支的远程源分支,这样每次只需要git pull

posted @ 2016-07-15 11:29  深海懒猫  阅读(130)  评论(0)    收藏  举报