gitflow 应用及git常用命令

https://www.git-tower.com/learn/git/ebook/cn/command-line/advanced-topics/git-flow (git-flow 的工作流程)

http://blog.csdn.net/zsm180/article/details/75291260 (GitFlow工作流常用操作流程)

 

       因为git2.6.0以后版本中已经自动包括了gitflow,故不用再安装gitflow了;

查看可以这样操作:

1、cmd命令行中执行  git version

C:\Windows\system32>git version

git version 2.14.1.windows.1

 

2、执行命令 git flow 出现如下界面表示git flow 已经安装

C:\Windows\system32>git flow

usage: git flow <subcommand>

 

Available subcommands are:

   init      Initialize a new git repo with support for the branching model.

   feature   Manage your feature branches.

   bugfix    Manage your bugfix branches.

   release   Manage your release branches.

   hotfix    Manage your hotfix branches.

   support   Manage your support branches.

   version   Shows version information.

   config    Manage your git-flow configuration.

   log       Show log deviating from base branch.

 

Try 'git flow <subcommand> help' for details.

 

3、在我们工厂目录中

    执行 

$ git config user.name "xxx.xiong"

$ git config user.email "[email protected]"

作为你的git提交用户名等;

 

在本地的master分支下执行 git flow init 出现如下界面:

   $ git flow init

No branches exist yet. Base branches must be created now.

Branch name for production releases: [master]

Branch name for "next release" development: [develop]

 

How to name your supporting branch prefixes?

Feature branches? [feature/]

Bugfix branches? [bugfix/]

Release branches? [release/]

Hotfix branches? [hotfix/]

Support branches? [support/]

Version tag prefix? []

Hooks and filters directory? [H:/develop/IDEA_workspace/chcloud/prime/prime-project/.git/hooks]

 

完成后自动切换到develop分支

yjph83@xxh MINGW64 /h/develop/IDEA_workspace/chcloud/prime/prime-project (develop)

  $ git flow feature start code-init

Switched to a new branch 'feature/code-init'

 

Summary of actions:

- A new branch 'feature/code-init' was created, based on 'develop'

- You are now on branch 'feature/code-init'

 

Now, start committing on your feature. When done, use:

 

     git flow feature finish code-init

 

 

当功能开发完成后,则我们必须执行

 $ git add .  ;  

 $ git commit -m "提交说明"  ;

z再执行   

$ git flow feature finish code-init     这样就OK了!

 

 

 常用的git命令如下:

1.查看分支

  a、看本地分支

    git branch 

    

  b、看远程分支

    git branch -r

    

  c、看所有分支(本地、远程)

    git branch -a

   

2.创建分支

  git branch 分支名     如:git branch dev

  

3.切换分支

  git checkout 分支名   如:git checkout dev

  

4.创建并切换到分支

  git checkout -b 分支名    如:git checkout -b dev    

  

5.master合并分支dev,必须先切换到master分支

  git merge dev

  

6.删除本地分支

  git branch -d 分支名      如:git branch -d dev

  

7.从远程分支master拉取代码

  git pull pub master

  

8.向origin主机的master分支提交代码

  git push origin master

  

  

9.从远程master分支拉取最新代码

  git pull origin master

  

10.推送本地有分支而远程没有的分支

  git push origin 新分支名         如:git push origin new_branch

  

11.从远程仓库里拉取一条本地不存在的分支时

  git checkout -b 本地分支名 origin/远程分支名

  有时不成功,则先执行:git fetch origin 远程分支名     #再执行拉取命令

12.删除远程分支

  git push [远程名] :[分支名]      如:git push origin:dev

13.本地提交代码是默认当前分支

  git commit -m "提交内容说明"

  

14.使用说明:

    合并到本地 develop分支后,

    1).git pull --rebase

    2).如无冲突,则直接git push origin develop

    3).有冲突,则修改代码,解决冲突

    4).解决冲突后,再将这些文件执行  git add 文件

    5).添加文件后,执行 git rebase --continue

    6).循环2)-6)步操作

    

15.git log    #查看本地提交记录

16.git reflog    #查看本地所有的提交记录(含reset的操作记录)

17.git reset 提交哈希码    #本地文件不变,从git log中删除commit的记录

18.git reset --hard 提交哈希码    #本地文件要变,从git log中删除commit的记录

 

 

 

 

 

 

猜你喜欢

转载自yjph83.iteye.com/blog/2413288