🐬 🐬 and Star 🐳 🐳

The git command line

  1. git clone

    • Used to copy a remote repository to the local
    • ssh: git clone username@host:/path/to/repository
    • https: git clone https:/path/to/repository.git
  2. git config

    • This command defines all configurations, from user information to warehouse behavior
    • Git config –global –edit: Editor opens configuration file
    • Git config –global user.name: git git config –global user
    • Git config –global user.email: git git config –global user
  3. git add

    • Commit local Workspace (Working Dir) changes to the cache (Index)
    • Git add: Commit the confirmation file
    • Git add * : Commit all changes
    • Git add-a: Commit the files in tracted and untracted to the cache
    • Git add -u: Commit the files in tracted to the cache
    • Git add-p: Interactive commit
  4. git commit

    • Commit the cached snapshot to the project history
    • Git commit -m “” : commit the cached snapshot. It runs a text editor and waits for you to enter your submission information. After you enter the information, save the file, close the editor, and create the actual commit.
  5. git status

    • List cached, uncached, untracked files (cache and workspace file states)
    • Changes to be committed: Files are in the cache
    • Changes not staged for COMMIT: Files that have been tracked in a workspace
    • Untracked Files: Files that are not tracked in the workspace
  6. git log

    • Command to display committed snapshots
  7. git checkout

    • This command does three different things: check out files, check out commits, and check out branches

    • Submit level

      • Move the HEAD pointer to the fixed commit
      • git checkout HEAD~2
      • git checkout
    • File level

      • Overwrite the files in the local workspace with the files in the committed version
      • git checkout HEAD~2 test.txt
      • Git Checkout HEAD

    • The branch level

      • Switch branch
      • git checkout
  8. git reset

    • If you change the commit version, you will delete the commit history (be careful). Do not use Git reset after pushing the commit to a remote device

    • Submit level

      • git reset –soft HEAD~2
      • git reset –soft

    In addition to working on the current branch, you can also modify your cache or working directory by passing in these flags:

    --soft -- neither cache nor working directory will be changed --mixed -- default option. The cache is synchronized with the submission you specify, but the working directory is not affected --hard -- both the cache and the working directory are synchronized to the submission you specifyCopy the code

    Common operations:

     git reset --mixed HEAD / git reset HEAD
     git reset --hard HEAD
    Copy the code
    • File level

      • Overwrite the files in the cache with the files in the committed version
      • git reset HEAD~2 text.txt
      • git reset HEAD

  9. git revert

    • When you undo a commit, Revert creates a new one. This is a safe method because it does not override the commit history.
    • git revert HEAD~2
      • The next-to-last commit is found, a new commit is created to undo those changes, and that commit is added to the project.

  10. git stash

    • Git Stash: Hold ongoing work
    • Git stash pop: Restore temporary files
    • Git Stash list: Displays the history of all staging in the staging stack
    • Git stash apply stash@{1} : Restores the temporary history specified
    • Git Stash clear: Clear the staging stack
  11. Bsde figure

  1. Refer to www.cnblogs.com/houpeiyong/… Github.com/geeeeeeeeek…