Git project learning --02- (Git branch, branch-based online repair bug, GitHub's use: home and company code synchronization application, a forgotten submit code case)

1, Git branch

Branch can provide the user with multiple environments, which means you can take your work separated from the main line of development, so as not to affect the main line of development.

Phase IV: Mall & emergency repair bug
bug ideas emergency repair line:
When C3 version of the software began to expand the new features of version produced C4, C4 version but this time there is a new bug, namely C5, C5 with this branch in emerging bug fixes, and then two branches: branch C5 bug fixes and software version on the normal line of C6 combined into a complete repair software version of C7.
Here Insert Picture Description
based online bug fix branch
currently located in your branch

git branch

Creating a branch

git branch branch name

Switching branch

git checkout branch name

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Branches merge (potential conflict)

git merge to merge the branch
consolidation time if something goes wrong, you can manually delete the wrong tags section .

Deleted branches

git branch -d branch name

Prior to the merger, it is necessary to switch to the main branch:
Here Insert Picture Description

2、GitHub

Phase V -> to enter the Sanlitun

Here Insert Picture Description
First, the need to register github account and create a remote repository, and then run the following command to upload the code to github.
Here Insert Picture Description

To a remote warehouse surnamed

git remote add origin remote warehouse address

Push code to the remote

git push -u origin branch

Here Insert Picture Description

For the first time in the company's new computer to download the code
clone remote repository Code

git clone a remote repository address

Switching branch

git checkout branch

After you download the code for the company to continue to develop
to switch to the dev branch development

git checkout dev

The master branch into dev (Update branch code files into a master code file saved latest online)

git merge master

Submit code

git add .
git commit -m “xxx”
git push origin dev

Here Insert Picture Description
Here Insert Picture Description

Completion of the development, to be on-line
to dev branches merged into master, carried out on-line

git checkout master
git merge dev
git push origin master

The branch also pushed to the remote dev

git checkout dev
git merge master
git push origin dev

Special case: Forget submit code

Pull Code

git pull origin dev

Submit code

git add .
git commit -m “xxx”

Note that at this time did not submit to GitHub hosting

Home to continue to write code
to pull the code, found no company code

git pull origin dev

But unfortunately, we continue to develop other functions
to be pushed to the remote branch dev

git add .
git commit -m “xxx”
git push origin dev

The company continues to write code to
pull the code, the code yesterday pulled the local (there may be a conflict)

git pull origin dev

Resolve conflicts, continue to develop this method of conflict resolution is a direct manually remove the abnormal part of the code, and then save out

The branch also pushed to the remote dev

git add .
git commit -m “xxx”
git push origin dev

Here Insert Picture Description

Published 60 original articles · won praise 9 · views 5037

Guess you like

Origin blog.csdn.net/weixin_42118531/article/details/104834794