Code submission process

0. The first thing that comes to the company every day is to update the code (git pull)
1. Process: Generally, we develop on the test-dev branch. When the development is completed, we push the code to test-dev On the branch, then, create your own master-xhc branch on the remote master branch, update the remote master-xhc branch to the local, and then put the code to be submitted (if you don’t submit it, don’t put it) on the master-xhc branch , Commit, and then push the local master_xhc to the remote branch.
Insert picture description here

2. Log in to gitlab, submit a merge request, and wait for the code reviewer to review the code http://git.webtrn.cn.
Insert picture description here

3. After the code is approved, send a confirmation email http://192.168.20.57:27295/ on the code confirmation platform.
4. Then switch back to the test-dev branch and continue your development!

git merge test_dev_tmp //Merge test_dev_tmp to the current branch
git push origin --delete master_zhengnan //Delete the remote branch
git branch -m master old-master //Modify the branch name
git push -f origin master_zhengnan //Push the branch to the remote branch
git fetch origin master:master_zhengnan //Open a new branch from master, the name of the branch is
git commit
-m'comment ' git push origin master_zhengnan //Submit the branch to the remote

mine===
Develop on the test-dev branch first. After the development is completed (remember to prevent the problem of full + full-, change File --" convert line Delimiters to --> unix), (if it is a new file, you must first To add the file to the temporary storage state, click add index in eclipse) and then select commit -->commit and push in eclipse (don't choose the wrong one).
git fetch origin master:master_xuehuichen (make a local branch remotely)
git checkout master_xuehuichen (switch to a local branch)
git checkout test-dev file directory (start from src, multiple files are separated by spaces)
git commit -m'this It is a comment' (submitted to local branch)
git push origin master_xuehuichen (push to remote branch)
2. Log in to gitlab, submit a merge request, and wait for the code reviewer to review the code http://git.webtrn.cn.

3. After the code is approved, send a confirmation email http://192.168.20.57:27295/ on the code confirmation platform.
4. Then switch back to the test-dev branch (git checkout test-dev) and continue your development!
5. Delete the local branch git branch -D master_xuehuichen
specifies the remote branch corresponding to the local branch: git branch --set-upstream-to=origin/test-dev

Delete inconsistent local and remote branches
git remote prune origin Roll
back to the latest state
git reset --hard HEAD

If the developer rearranges the master and test-dev branches, then execute the following command on the test-dev branch
git fetch --all
git reset --hard origin/test-dev
git pull

Or, switch to another branch first, delete the local test-dev, then reopen a test-dev branch
Delete the local branch git branch -D master_xuehuichen
reopen a branch git fetch origin test-dev:test-dev

$ git push origin --delete <branchName>

The ultimate artifact to restore remote consistency (do not use it under normal circumstances!!!)
git fetch --all
git reset --hard origin/test-dev
git pull

If it doesn’t work, make a new branch,
Insert picture description here
Insert picture description here

Delete the original reference
Insert picture description here

Also, if the file conflicts, if you haven’t changed the file, just delete your own part.

File submission in case of many documents=======
When there are many files to be submitted, it is impossible to copy them one by one, as follows:
1. Submit the files to test-dev, and then check the submitted files on the test-dev branch in eclipse
Go to the desktop, 2. Switch to the master_xuehuichen branch, and overwrite the project location (src) with the folder just exported under the windows environment.
3. If you need to add, just add, if you don’t need to commit, then push the local master_xuehuichen to the remote and merge the master Then,
4. Switch to test-dev to continue development.

When the file you want to submit contains a compiled file, it is usually added to the list of git ignored. At this time, you can't submit it. How to do
: switch to the navig view and find the .ignore file corresponding to the file , Ignore the deletion first. Then add index to the file to be submitted, and then restore the .ignore file to its original state. At this time, you can submit the file. As shown below
Insert picture description here


When you open the git black window happily in the morning and enter git pull, you find that today git is a bit different from usual. It will print out more prompts on the console that you don’t usually see
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping. At
this time, you are in a daze. I didn't do anything. How could this error occur. In fact, this is because there are too many loose objects in git, and git is overwhelmed. You only need to clean up the garbage and
type "git gc", but at this time, it reports an error
Rename from'.git/objects/pack/pack -e3f69d1da4c4462f6b5dd136d481e158c21eb34e.pack' to'.git/objects/pack/old-e3f69d1da4c4462f6b5dd136d481e158c21eb34e.pack' failed. Should I try again? (y/n) nThis
is an urgent task
, don’t you ~~~~ Is it because your eclipse is on? If eclipse is on, then you can turn it off and try again. At this time, you will find out, okay? ? ! ! !
It is because eclipse is driving some git files, these files are occupied, so they cannot be operated on. This time, you can develop normally by running git pull! !


Insert picture description here

-----------Restore the master code process,
first make a previous branch
Insert picture description here

Next, make a new branch
Insert picture description here

Checkout the file to be restored from the previous branch to the latest branch
Insert picture description here


Git: common solutions to code conflicts

If there are some configuration files in the system that have been modified on the server, and then some new configuration items are added in subsequent development
, code conflicts will occur when this configuration file is released:
error: Your local changes to the following files would be overwritten by merge:
protected/config/main.php
Please, commit your changes or stash them before you can merge.
If you want to keep the changes made on the production server, just merge the new configuration items, the processing method is as follows:
Method 1: If you want to keep the code you just modified locally, and pull the code on the git server to the local (the code just modified locally will be temporarily sealed)
git stash
git pull
git stash pop
then you can use git diff -w + file name To confirm that the code is automatically merged.

Conversely, if you want to completely cover the local working version with the files in the code base. The method is as follows:
git reset --hard
git pull
where git reset is for the version, if you want to roll back local modifications to the file, use
[plain] view plain copy
git checkout HEAD file/to/restore

git stash和git stash pop

Git stash can be used to temporarily store the current work in progress, such as pulling the latest code but not adding a new commit, or another situation, in order to fix an urgent bug, first stash, so that you can return to your previous commit, and finish the change. Stash pop after the bug and continue the original work.
Basic command:
$git stash
$do some work
$git stash pop

Advanced:
git stash save "work in progress for foo feature"
When you use the'git stash' command many times, your stack will be full of uncommitted code. At this time, you will be a little confused about which version to apply back. ,
'Git stash list' command can print out the current Git stack information, you only need to find the corresponding version number, for example, use'git stash apply stash@{1}' to assign you the version number to stash@{ 1} Take out the work, when you apply all the stack back, you can use'git stash clear' to clear the stack.

git stash # save uncommitted changes

pull, edit, etc.

git stash list # list stashed changes in this git
git show stash@{0} # see the last stash
git stash pop # apply last stash and remove it from the list

git stash --help # for more info

----------------------------Own project------------------- ----------------Merge branches
Insert picture description here

Force branch switch: git checkout test-dev -f

I encountered a problem today: Two functional modules were developed at the same time on test-dev, one completed and one unfinished. The unfinished ones are two newly created files. I added them to the git index, but did not submit to the remote test. -dev, I only submit the completed code to test-dev. When I fetch down a master_xuehuichen branch, I just switch the completed code to master_xuehuichen. The unfinished code does not switch. After I push the remote, after switching back to test-dev, I added to the git index before The code is gone! ! ! In the future, unfinished functions will also be submitted to test-dev!!!

Guess you like

Origin blog.csdn.net/nonage_bread/article/details/112217093