Skip to content

SeanXiaoby/git-workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How I learn to work with git


Branch Operations

Technically, you have to make every modification on the branch and merge it to the main branch. You can create a branch on the current branch.

Commands

To create a new branch:

git branch <branch_name>

To change to a specific branch:

git checkout <branch_name>

To delete a branch from local repo:

git branch -d <branch_name1> <branch_name2> ...

To fetch a remote branch to the local repo:

git fetch origin <remote_branch_name>:<local_branch_name>

To push a local branch to the remote branch:

git push origin <local_branch>:<remote_branch>

Merging Operations

There are two ways to merge the branch to the local branch:

  • Merge the branch to the main branch locally and push the main to the remote repo
  • Push all the commits to the remote repo and send a pull request (recommended if I am not the owner of the repo)

Commands

To merge a local branch to the local main branch:

git checkout <branch1> ## switch to the main branch first
git merge <branch2> ## Merge branch2 to the branch1

About

How I learn to work with git

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published