Very important and basic six Git commands

Hello! My name is Itchao, I am a craftsman who just started to work. I want to learn git command, please follow me! Enjoy the coquettish of excellent programmer together from now on! Go! Set off!

OK! For those of you who click on this blog, I assume you are either a new employee or a student learning git commands! You’ve come to the right place. Here are six basic commands to understand what Git can do, what you can learn with it, and how to use it.

Set off!

Let’s imagine some scenarios together! Learn more about how to use git commands in real situations!

Scenario 1: You are a fresh graduate. As a fresh graduate, you are very happy to find your first job. On your first day on the job, your supervisor gives you permission to pull down the code and ask you to take a look at the company’s code first. Key words: pull code! Clone the code from the company’s repository to your own repository.

  • Clone code repository:
Git Clone 'repository'Copy the code

Very good! Now that you know how to pull code locally, you can begin to have fun on your own! Come on!

Scene 2: Hello! Hello again, you’ve finished your code development so quickly and need to submit it to the company’s repository. Cool! Then we continue to travel in the world of code!

  • The first step: Keep your code in sync with your company’s repository (update local code) before submitting your code to avoid unnecessary errors (advice)
    • The code is as follows:
    git pull origin master
    Copy the code
    • Code explanation:
      • Git pull: Synchronize your native code with your company’s latest repository
      • Origin: the name of the repository. The default value is Origin, which can also be modified based on actual needs
      • Master: Branch development. There are many kinds of branches. Write master here for example
  • The second step: Submit your own code to the staging area
    • The code is as follows:
    git add .
    Copy the code
    • Code explanation:
      • Git add: Commit code to staging area
      • . : The representative submits all documents
      • Note: add.(with Spaces in between!)
  • The third stepCommit all files in the staging area to the master branch (or other branches, depending on your needs)
    • The code is as follows:
    Git commit -mCopy the code
    • Code explanation:
      • Git commit: Commit your changes to the master branch (or another branch, depending on your needs)
      • -m: indicates that the description of the submitted code can be added
      • ‘Code description of the code submitted ‘: The description of the code submitted should be added, as the company generally requires
        • Description information format (for reference only) : [submitted by] Kasha [submitted content] Add [Added content] Get five kill
  • The fourth step: Push the code above the branch to the company code repository to complete the code submission
    • The code is as follows:
    git push origin master
    Copy the code
    • Code explanation:
      • Git push: Push code from local to corporate repository
      • Origin: the name of the repository
      • Master: The branch currently under development
  • Check the status(More commonly used)
    • The code is as follows:
    git status
    Copy the code
    • Code explanation:
      • Git status: check which files are committed and which are not
  • You’re amazing! What an excellent first job assignment! Your company is lucky to have you! Good refueling! I will be a very good development engineer in the future!
  • Git command summary:
    • Git clone ‘git repository’
    • Git pull Origin Master: Update local code to be consistent with remote repository code
    • Git add. : Commits local code to staging
    • Git commit -m ‘Commit code description’ : this is the description of the commit code, convenient for the company code repository code management
    • Git push origin master: Push code to a remote repository
    • Git status: Check the status of files to see which files are not committed and which files are committed

Congratulations! Congratulations to you! Completed the first code development in the company code and successfully submitted to the company code warehouse! Very fierce! Keep it up!

Congratulations on your successful completion of the first code submission in the company, this blog is almost over. This blog is relatively simple, mainly to let you have a preliminary understanding of Git, not afraid of git command, also let you familiar with the common use of Git, know the importance of git command. So I can take the time to learn git commands seriously! I will probably explain git commands in more detail later, but I will arrange this later! Come on!

I write this blog is relatively simple, recommend a system and better git command learning document:

Git tutorial in liao Xuefeng’s official documentation:www.liaoxuefeng.com/wiki/896043…
  • Put my phone screensaver words, give you, come on together!

    • Don’t limit yourself!
    • Don’t doubt yourself!
    • Work hard!
    • Be an excellent person!

Hello! My name is ITchao. I am a craftsman who just joined the front office. I am very glad to meet you and look forward to seeing you next time! Itchao 3 September 2021 09:36:57