preface

Recently moved from SVN to Git, here are two beginner’s Git workflows to help with the transition from SVN to Git, and after the next two streams have played 6, you can try a more “high-end” one

Centralized workflow

Core: There is only one branch, master

Features: The flow is almost the same as that of the SVN

Members pull items for the first time

$ git clone <url>
Copy the code

Members push local submissions to the central repository

$ git push origin master
Copy the code

If there is a difference between local and remote, Git will reject the operation, so we pull and base at the same time

$ git pull --rebase origin master
Copy the code

CONFLICT (content): Merge CONFLICT in

Fix conflicts manually, while always checking conflicting files with git status

$ git status
Copy the code

After the conflict is fixed

$ git add <file>
$ git rebase --continue
Copy the code

Repeat this process until there are no conflicts pushed to remote

$ git push origin master
Copy the code

If you can’t resolve the conflict, or if you mess it up, don’t panic. Go back to git pull –rebase

$ git rebase --abort
Copy the code

Functional branch workflow

Core: There is a master branch, and a new branch is opened to develop new functions and fix bugs. Pull Request is used to create the master branch

Features: Simple branching and pull request

Create a new branch

$git branch feature master $git checkout featureCopy the code

Modify commit in this branch…

$ git status
$ git add
$ git commit
Copy the code

Synchronize branches to the central repository

$ git push -u origin feature
Copy the code

After the functionality is developed, initiate a Pull Request (Merge Request) on the project page.

When you confirm that you can merge, merge and delete local and remote branches

$ git branch -d feature
$ git push origin --delete feature
Copy the code