Git handles the problem of committing code without pulling it
Problem Description:
When submitting modified local code, remote pull was not performed and the local code lagged behind the remote code causing an error that could not be submitted
Solutions and methods:
- Create a new branch, fix
Git branch fix Copy the code
- 2. Find the head in the original branch and force it back to the head before you commit
The Git log; Git reset -- Hard head valueCopy the code
- 3. Then re-pull the code
- 4. From the FIX branch, select the commit that you want to keep and commit
Git cherry-pick xxxhead1 xxxhead2 Copy the code
Multiple commit-hashes (xxxhead) are separated by Spaces. It is better to arrange commit-hashes by commit time first, that is, the commit submitted first is placed first.
Git add. Git commit -m "commitCopy the code
- Commit the update and delete the Fix branch
Git branch -D fix Copy the code