This is the first day of my participation in Gwen Challenge

preface

The first two Git notes are mainly about the installation of Git and the underlying commands, but the underlying commands are almost not involved in the actual development, because the underlying commands are troublesome to remember and prone to error. Since the actual development process doesn’t use low-level commands, why learn? The bottom command is the soul of Git and the top command is the body of Git. If you only learn Git’s top command, you will have no soul. Now that we have Git’s soul, it’s time to start getting Git’s body.

First, high-level orders

Initialize the warehouse

  • git init

This command has been used previously to initialize Git repositories.

Add the changes to the staging area

  • Git add Specifies the path to the git file

All talk and no practice, so we should give it a try. Git ls-files-s and find./. Git /objects/ -type f.

Git add is a combination of git hash-object-w and git updata-index. Git add is a combination of git hash-object-w and git updata-index.

Commit the contents of the staging area to the repository

  • git commit -m “infromation”
  • Git commit “allows you to write a lot of information in the Vim editor
  • Git commit -a -m “infromation” skip the staging area and enter git add.

The git commit command is a combination of git write-tree and git commit-tree. (I’m sure I’ll demonstrate the simplest hahaha, the rest for you to practice)

There is only one object in the repository when you don’t use git commit. When you run out of git commit, there are three objects in the repository.

Check the current file status

  • git status

First of all, we need to know that the file has two major states: tracked and untracked, which are divided into temporary, committed and modified.

The actions we take are different depending on the state of the file. If the file is not tracked then we need to track it. If the file is in modified then we should save it temporarily. Git status: git status: git status: git status: git status: git status: git status: git status: git status No more nonsense to say directly above! (I hope you can try Git yourself!)

Detects both staged and unstaged updates

  • git diff
  • git diff –cached

In the case of Git status, git diff allows us to see in more detail what to change. Git diff: is the current operation modified but not saved? GIF diff –cached command those things are temporarily stored but not committed. (Ps: Try it yourself!)

Delete the file

  • Rm File path
  • Git rm file path (save git add command)

To remove a file from Git, you must delete it from the list of files that have been tracked. We know from the above experiment that the file will be tracked after Git add is executed, so we need to delete it from the staging area. Git will definitely not delete it for us. Deleting it is only the appearance of deleting it, but in essence, it is the addition of the operation.

Git commit: Delete the new. TXT file from the working directory, remove the new. TXT snapshot from the staging area, and create a tree object from the snapshot. So we’re going to add two objects to our repository a tree object and a commit object.

File renaming

  • mv fileName newFileName
  • Git mv fileName newFileName

Git mv git mv git mv git mv git rm name; git add newName; Directly above (mv shown in the figure)

See the log

  • git log –oneline

This has no what to say is to see the relevant log, this everybody tries ok SO~~easy!

Second, the end

So far Git often used high-level command on the end of the story next time is about Git the most the most coddle branch function ha ha ha, if feel useful can point a thumb-up oh! I will continue to update, if there are any mistakes please point out, thank you for your audience master.

To get a PDF of the above content, go to GitHub and download it.

Address: Git study notes area

— — — — — a romantic