Git Stash related operations

  1. Git Stash is used to cache changes and replace branches without committing changes
  2. Git Stash pop takes the latest one-day cache from the cache and updates it to the current branch
  3. Check out the Stash cache list
  4. Git stash apply stash@{id} When multiple Stash caches exist, it is used to restore the cache with the specified ID. You can view the ID through the list
  5. Git Stash clear Clears all stash caches
  6. Git stash drop Stash @{id} Clears the stash cache for the specified ID

Create and delete local branches and remote branches

  1. Git branch -a Displays branches
  2. Git branch dev creates a branch
  3. Git checkout dev switches to a branch
  4. Git branch -d dev Deletes a local branch
  5. Git push origin –delete dev deletes the remote branch

3. Change the branch name

  1. Git branch -a Displays all branches
  2. Git branch -r Displays remote branches
  3. Git branch -vv Displays remote branches associated with the local branch
  4. Git branch -m old_branch new_branch Renames a branch
  5. Git push origin :old_branch Deletes the old local name
  6. Git push –set-upstream origin new_branch pushes the new name to the remote branch

4. Pull the latest content onto the master branch

  1. Git pull origin Master violence method: Directly pull the latest content on the master and merge it to the local master branch
  2. Git fetch origin master + git merge origin/master Git merge origin/master

5. CRLF and LF

  1. git config –global core.autocrlf true

Git can automatically convert CRLF to LF when you push and CRLF to CRLF when you pull. Change the function by using core. Autocrat LF and (for Windows) set it to true so that the change of LF becomes CRLF when the code is checked out

  1. git config –global core.autocrlf input

Linux or Mac systems use LF as the line terminator; Eventually you’ll want to fix a file that has CRLF at the end of a line by mistake, and change core. Autocrat LF to input to tell Git to change CRLF to LF for push and not for pull

  1. git config –global core.autocrlf false

CRLF is kept both locally and in the codebase, regardless of pull or push. What does the codebase look like, native or what

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  1. git add .
  2. Git commit -m ‘commit description’ (normal commit) git commit –amend (signed-off-by: yourname <*****@qq.com> add this to the popup file, and then esc :wq exit)
  3. Git push –force-with-lease (git push -f) git push –force-with-lease (git push -f) git push –force-with-lease (git push -f

7, pull the latest content of the master branch to other local branches, application scenarios need to rely on the latest update of the master content, such as the need to use the new icon component of the Master branch

  1. Git Checkout Master switch to the master branch
  2. Git pull Pull the latest content from the remote master branch and merge it with the local master
  3. Git checkout dev switches to the branch
  4. Git merge master merge master git merge master
  5. Git add. commit after conflict resolution
  6. Git commit Commits the changes
  7. Git push –force-with-lease (git push -f) –force-with-lease (git push -f) –force-with-lease (git push -f

Add local branch to master

  1. Git Checkout Master switch to the master branch
  2. Git pull Pull the latest content from the remote master branch and merge it with the local master
  3. Git checkout dev switches to the branch
  4. Git rebase master compresses the local branch with the latest content of the master
  5. Git add. commit after conflict resolution
  6. Git rebase –continue to compress
  7. Git push –force-with-lease (git push -f) –force-with-lease (git push -f) –force-with-lease (git push -f

Use rebase to compress the commit

  1. Git log to view commit history
  2. Git rebase -i HEAD~4 git rebase -i HEAD~4 git rebase -i HEAD~4
  3. After the preceding statement is executed, a file is displayed. If all picks except the first pick are changed to squash, all commit is compressed to the commit in the first line of the file. After the modification is complete, esc :wq exits
  4. If there is a conflict, resolve it
  5. git add .
  6. Git rebase –continue Continues compression. If you want to abort the compression, run git rebase –abort
  7. If all conflicts have been resolved, delete all the contents before Please Enter and write a new sentence. This is the commit comment and exit esc :wq
  8. Git log check and find that the compressed
  9. Git push –force-with-lease (git push -f) –force-with-lease (git push -f) –force-with-lease (git push -f

Delete local and remote branches

  1. Git Checkout Master switch to the master branch, or another branch that is not deleted
  2. Git branch -a Views existing local and remote branches
  3. Git push origin –delete dev deletes the remote dev branch
  4. Git branch -d dev Deletes the local dev branch
  5. Git branch -a after deletion, check the branch status again