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
}
(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
}