Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
git-research
git-research
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 12
    • Issues 12
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Đào Nguyễn Thành Uy
  • git-researchgit-research
  • Wiki
  • create a new branch with git and manage branches

create a new branch with git and manage branches · Changes

Page history
thanhuy.nguyen created page: create a new branch with git and manage branches authored Aug 21, 2019 by Đào Nguyễn Thành Uy's avatar Đào Nguyễn Thành Uy
Show whitespace changes
Inline Side-by-side
Showing with 54 additions and 0 deletions
+54 -0
  • create-a-new-branch-with-git-and-manage-branches.md create-a-new-branch-with-git-and-manage-branches.md +54 -0
  • No files found.
create-a-new-branch-with-git-and-manage-branches.md 0 → 100644
View page @ 935a3c4a
**Create a new branch with git and manage branches**
When you do a pull request on a branch, you can continue to work on another branch and make another pull request on this other branch.
Before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
> $ git pull
Create the branch on your local machine and switch in this branch :
> $ git checkout -b [name_of_your_new_branch]
Push the branch on github :
> $ git push origin [name_of_your_new_branch]
When you want to commit something in your branch, be sure to be in your branch. Add -u parameter to set upstream.
You can see all branches created by using :
> $ git branch -a
Which will show :
> approval_messages
master
master_clean
Add a new remote for your branch :
> $ git remote add [name_of_your_remote] [name_of_your_new_branch]
Push changes from your commit into your branch :
> $ git push [name_of_your_new_remote] [url]
Update your branch when the original branch from official repository has been updated :
> $ git fetch [name_of_your_remote]
Then you need to apply to merge changes, if your branch is derivated from develop you need to do :
> $ git merge [name_of_your_remote]/develop
Delete a branch on your local filesystem :
> $ git branch -d [name_of_your_new_branch]
To force the deletion of local branch on your filesystem :
> $ git branch -D [name_of_your_new_branch]
Delete the branch on github :
$ git push origin :[name_of_your_new_branch]
\ No newline at end of file
Clone repository
  • create a new branch with git and manage branches
  • Home