This is the fifth day of my participation in the August More text Challenge. For details, see:August is more challenging

Personal technical blog, wechat official account, video account and design portfolio of the blogger

This is a quick summary of the frequent questions people ask about git commit code for multiple developers.

I. Basic process of Remote repository of Git code submitted during work:

Basic process:

  1. Push your own code to the remote repository
  2. Stash cache the local code first (in case someone else has changed it and there’s a conflict)
  3. Then pull the remote code
  4. After the pull, the Stash Pop throws the local code
  5. If there is a conflict, resolve the conflict file according to the prompt. If there is no conflict file, add the temporary storage area directly
  6. Commit Note
  7. Push to a remote repository

The following describes the operation commands

1. View the remote branch

git branch -a

2. Switch branches

git checkout xxx

3. Back up the contents of the current workspace

git stash

4. Pull the code

git pull

5. Throw the backup local code

git stash pop

6. Submit the description of remote warehouse

git commit -m “xxxxx”

7, save the code of the workspace to the staging area (there are three commands to choose)

  • git add .(Save all files in the current workspace to the staging area)
  • git add -u(Submit all changed files, i.e., submit all changed files)
  • git add -A(Commit modified and deleted files, but not new files)

8. Push local code to remote repositories (different suffixes depending on the project)

git push origin HEAD:refs/for/dev

Second, when the submission of the problem of the solution command

Basic process:

  1. First look at the log
  2. Reset –soft Rollback to a version that does not conflict (soft rollback)
  3. And stash caches this code
  4. Pull remote code
  5. Stash Pop Throws the local backup code
  6. If there is a conflict, resolve the conflict, and then add
  7. commit
  8. push

The operation commands are described as follows

1. View logs

git log

2. Roll back the version (select the two commands)

  • Git reset –hard XXX (both local files and commit information are rolled backA dev | MERGING)
  • Git reset –soft XXX (the local file is still there when the commit information has been rolled back)

4. Modify the last commit to merge two commits into one commit (i.e. -m ‘log’)

  • git commit –amend
  • git commit –amend -m “xxxxxx”

Discard the merge process and try to recreate the pre-merge state (used in case of post-merge problems)

git merge –abort

6, no parameter is the default comparison between workspace and staging area

git diff