GIT 创建分支,D代码常用命令

Create features/tasks branch 
(1)git fetch   
    to get the latest branches from central repo
(2)git branch -r | grep -i <name> 
    To search for tasks or features  remote branches, or  release branches,
example:  git branch -r | grep -i release
(3)Creating and checking out new branches:
    git checkout -b tasks/$USER/<task name> 
       > Create and checkout a new local task branch
    git checkout –b features/<feature name>
       > To create and checkout a new local feature branch 
(4)Checking out existing branches:
    git checkout features/<feature name>
       > Checkout an existing branch
(5)Command to create remote branch and push to it (use same name as your local task branch) 
    git push -u origin HEAD:tasks/$USER/<branchname> 
(6)Create a new local branch, from the current branch & change to it
    git checkout –b <new_branch_name>
(7)Create a branch from another branch
    git branch <new_branch_name> <from_branch_name>
(8)Change branches
    git checkout <branch_name>            (works for already created branch)
(9)Create a local branch, from the current branch
    git branch <branch_name>
(10)Delete a local branch
    git branch –d <branch_name> The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream.
    git branch –D <branch_name> The branch will be deleted irrespective of its merged status.
(11)Rename my current local branch
    git branch –m <new_branch>
(12)Copy a file or dir from another branch to my current branch
    git checkout <from-branch> -- <file_or_dir_path>
(13)Change the upstream tracking branch
    git branch -u <to-branch>

Delivery code to feature branch
(1)git status
(2)git diff
(3)git add
(4)git commit or git commit --amend
(5)git pull --rebase
(6)git push origin HEAD:refs/for/features/feature_name

Merge from feature branch to master
(1)git checkout master
(2)git merge --squash origin/features/feature_name
(3)gitk
(4)git status
(5)git commit  
(6)git pull --rebase
(7)git push origin HEAD:refs/for/master

Delivery code to master
(1)git checkout master
(2)git status
(3)git commit
(4)git pull --rebase
(5)git push origin HEAD:refs/for/master

Merge from master to feature branch
  git checkout master
  git pull --rebase
  git checkout features/feature_name
  git merge --no-ff origin/master
  If there are no conflicts
  {
     git commit --amend 
     git push origin HEAD:refs/for/features/feature_name
  }
  else #there are conflicts
  {
     git mergetool
     git status
     git commit
     git push origin HEAD:refs/for/features/feature_name
  }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值