git create a new branch and push (push) to the remote warehouse

git create a new branch and push (push) to the remote warehouse

For example, you already have a project, and the project has been pushed to a remote warehouse. Now the project needs to develop a new function, or to make some changes, you need to create a new branch.
The steps are as follows:
I use gitLab as an example here

1. Create a new branch in the remote warehouse first

  1. New branch

Insert picture description here

  1. The name of the remote branch

Insert picture description here

2. Create a new local branch

Note: Before creating a new branch, make sure that all changes to the current branch have been submitted cleanly, and ensure that the workspace is clean

  1. git statusCommand first check the status of the current branch
$ git status
On branch test
Your branch is up to date with 'origin/test'.
nothing to commit, working tree clean

The above means that you are in a testbranch now , without any commits, and the workspace is clean


  1. At this time, you can create a new local branch and use the git checkout -b 分支名command
git checkout -b bigScreen

After pressing Enter, a new branch is created locally, and the git statussituation is checked through commands. At this time, the local bigScreen branch has been created and switched to the changed branch.

$ git status
On branch bigScreen
nothing to commit, working tree clean

  1. After making changes to the code, check the status again, it prompts that a file has been modified, use the git add .command to update the content to be submitted
$ git status
On branch bigScreen
Changes not staged for commit:
 (use "git add <file>..." to update what will be committed)
 (use "git checkout -- <file>..." to discard changes in working directory)

       modified:   src/components/login.vue

no changes added to commit (use "git add" and/or "git commit -a")

git add .
  1. By git commit -m '本次提交说明文字'submitting content to the local store to the local staging area
git commit -m '2021.01.28 删除了logo图标'
[bigScreen e3333d9] 2021.01.28 鍒犻櫎浜唋ogo鍥炬爣
 1 file changed, 1 insertion(+), 1 deletion(-)

  1. By git push origin 远程仓库分支名the locally stored content submitted to a remote repository that just the new branch up
git push origin bigScreen

Completed the new branch and submitted it to the remote warehouse

Guess you like

Origin blog.csdn.net/weixin_47160442/article/details/113339319