Multi-branch git repository project management

A few days ago the boss requires git repository version changes that git repository migration, but instead of the three branches (dev, test, master) project management branch, before the project contains only a master branch.

Solve commit records before preservation at the same time warehouse migration?

(1) project initially thought the new address of the warehouse can be cloned down, copy the contents of the original project to the new project directory, and then re-upload the content, but this will overwrite the previous commit log; assume that when the project is very large, the cloning and re-upload need to spend a lot of time.

(2) using a mirror, a two-step migration can be completed warehouse.

①cd into the local repository under .git directory;

② Granted the new warehouse address by git push --mirror http: //xxx//new-template.git local warehouse pushed to the distal end of the warehouse, new-template for the new warehouse project address.

Multi-branch project management?

dev: development branch, usually for project development.

test: testing branch, the branch provides project testing to the test, dev and test content to stay in the same branch.

master: main branch, project release, bidding by branch.

** View project the current branch git branch -a // At this point the project exists only master the main branch

(1) establish a dev, test branch, and to achieve one correspondence between the local branch and a remote branch (dev -> origin / dev, test -> origin / test, master -> origin / master).

① establish a local branch: git checkout -b test

② will automatically sync when mapping relationship between the local branch and remote branch, then the branches after the push and pull: git push --set-upstream origin test

dev and test branch branch to establish a consistent method.

At first the establishment of three branches of the content should be the same, hence the need for consolidated branch content.

③ The combined current branch to a specified branch: git merge dev

④ to switch back to the main branch, to see all the branches.

Then you can manage multiple branches of the project.

Solve problems that occur when branches merge?

(1) | MERGING situation?

Undo merge: git reset --hard head

(2)出现Please enter a commit message to explain why this merge is necessary.

Key "Esc", enter ": wq", the Enter key will return to normal command line page.

(3) addressing the git pull branch code or checkout time, appears: Please commit your changes or stash them before you ...... then there are two cases.

I want to save local modifications just three steps:

①git stash // the current workspace to restore the contents of the last committed, while backup changes made to local

②git pull // changes made to pull remote

③git stash pop // backup workspace to restore the contents of the current work area

Confirmation code automatically merges case: git diff -w + filename

Local modifications to give up just two steps:

①git reset --hard

②git pull

 

 

Published 24 original articles · won praise 3 · views 20000 +

Guess you like

Origin blog.csdn.net/sunny123x/article/details/102366455