git resolve conflicts

Good way:
git pull --rebase
modify
Git stash
Git pull --rebase
Git stash pop
Git add .
Git commit -m ''
git push origin HEAD:refs/for/dev

 

Scenario 1:
Undo the modification of the workspace: git checkout -- file
Scenario 2:
Undo the modification of the temporary storage area (only add has not yet committed): 1. Undo a single file or folder: git reset HEAD -filename 2. Undo all The files that have been added: git reset HEAD.
Scenario 3: The
commit has not been pushed to the remote: git reset --hard HEAD^ (version rollback)

 

 

Soft git operation steps

- [ ] git branch -av Make sure that it is under the dev branch, if it is not under this branch, use git checkout dev to switch to this branch
- [ ] Check the status of the modified files, git status
- [ ] Red modification files, you need to pass git add **, added to git control, then the color will turn green
- [ ] Via git commit -m "Bugfix: ....", commit to local repository
- [ ] Via git push origin HEAD:refs/for/dev, push to the remote repository

- [ ] Through git pull --rebase, you can pull the code of the remote warehouse to the local, pay attention to the branch, pull the remote A branch to the local B branch, it will automatically merge, remember! !

After submitting to gerrit, when the modification is required to be submitted again:
- [ ] git add ***
- [ ] Check the content of this modification through git diff --cached
- [ ] Submit to the local warehouse: git commit --amend, put this The content of the second revision overwrites the latest submission. If the latest submission is submitted by someone else, there will be problems at this time! ! !
- [ ] Push to remote warehouse: git push origin HEAD:refs/for/dev
Push dev code to pre, and in a straight line: git push origin dev:pre

Delete a local branch:
- [ ] git branch -d tmp (-D forced deletion, cannot delete the current branch)

Track Git project source code:
- [ ] gitk --all&

Take the remote dev branch and fork a new branch tmp:
- [ ] git checkout -b tmp origin/dev

Put the commit (de56ab78b4911fd648b8b86a46571db217a86b9e) on a local branch into the current branch: - [
] git cherry-pick de56ab78b4911fd648b8b86a46571db217a86b9e
If there is a conflict, you must first resolve the conflict, then continue, or through abort
git cherry-pick --continue
- [ ] git cherry-pick --abort

push to the remote repository:
- [ ] git push origin HEAD:refs/for/dev

Go back to a certain version:
- [ ] git reset --hard {commitID}, go back to the specified version
- [ ] git reset --hard HEAD^, go back to the previous version
- [ ] git reset --hard HEAD^^ , go back to the previous version

Undo changes
- [ ] git checkout -- <file>, discard changes in the workspace
- [ ] git reset HEAD <file>, undo changes in the staging area and put them in the workspace

Undo the commit after git push
- [ ] git revert {commitId}, then git push. Generate a revert commit
- [ ] git reset --hard {commitID}, then git push. No new commits are made. But there is a risk that it is easy to revoke a peer's commit to

1. git pull --rebase
2. Modify
3. git add -A
4. git commit -m "BOSS-1172: review status"
3. git push origin HEAD: refs/for/dev

Conflict resolution:
git log

 

 

1. The first is to clone the project
<pre data-lang="-1">git clone project address

Modify the submitter's nickname
git config --global user.name "your name (can be Chinese)"
</pre>
2. Then enter the code directory

<b>Common commands</b> are:
<pre>Add
git add file name //Add a single file
git add -A //Add all files

Submit
git commit -am "comment content" //Submitting to the branch
git add command actually puts all the changes to be submitted into the staging area (Stage), and then executing git commit can put all the changes in the staging area at one time change commit to branch

update
git pull // update

push
git push origin branch name//push to the server

View status
git status

View commit history
git log

File comparison
git diff //Comparison of working files with temporary files
git diff --cached //Temporary files and submitted files
git diff --staged //Temporary files and submitted files

Remove the file
git rm
git rm --cached readme.txt //Remove from the staging area and warehouse, and no longer track this file in the future


Move or rename
git mv</pre>


<b>Uncommon commands</b>:


The <pre>return needed to resolve the version conflict
git revert HEAD //return to the last commit
git revert HEAD^ //return to the last commit, you can add "^" to go back to the previous commit
-- ------- Note that after revert rolls back the working directory, you can immediately make a latest commit, which is equivalent to copying an old version to the latest location

reset
git reset --hard HEAD //Reset working directory (excluding untracked files)
--------- To restore a single file, you can checkout that file: git checkout -- filename

Merge
git merge hotfix //Merge the hotfix branch to the current branch. Note that it is just a merge, the result after the merge is not submitted commit
git merge upstream/master //Merge a remote fetched branch
</pre>
 


<b>Submission process</b>:
<pre>
1. Switch to the develop branch git checkout develop

2. Pull the latest code of develop git pull origin develop

3. Create your own code branch based on develop git branch your branch name

4. Develop and modify new files in your own branch

5. If there are new files, git add the file name and multiple files can be git add -A

6. Submit to the local repository git commit -am "Submit change information" Commit message must be filled in

7. Push to the remote branch git push origin your branch name

</pre>

Switch to develop pull then switch to zhuleixiao merge develop then modify the local code then commit and finally push

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325311618&siteId=291194637