git branch

Git-Flow

Installation

  1. Install Plugins on MacOS
1
brew install git-flow
  1. search git-flow plugin

reflog

1
2
3
git reflog
git reset 'HEAD@{1}'
git reflog show master

Tag

create tag

1
git tag branch tag_name

push tag

1
git push --tags

view tag

1
git tag -l

sync tag

1
git fetch origin --prune --tags

delete tag

  1. delete all tags in remote

    1
    git tag -l | xargs -n 1 git push --delete origin
  2. delete all tags in local

    1
    git tag | xargs git tag -d
  3. delete a tag

1
2
3
git push --delete origin tagname

git tag --delete tagname

Branch

查看分支

查看本地分支

1
git branch

分支带有**前缀表示当前所在分支


查看远程分支

1
git branch -r

查看本地和远程分支

1
git branch -a

创建分支(不包含分支切换)

1
git branch new_branch

空白分支

1
2
git checkout --orphan branch-name
git rm -rf .

删除分支

删除本地分支

1
2
# -D 强制
git branch -d branch

删除远程分支

1
git branch -d -r branch

重命名分支

1
2
# -M 强制
git branch -m old_branch new_branch

切换分支

1
git checkout branch

合并分支代码

1
git merge origin/dev

Rollback

1
2
git reset --hard id
git push -f origin branch_name