Basic steps to use Git

Git is an open source distributed version control system for agile and efficient handling of projects of any size.

 The basic steps for using Git are described below:

  1. Install Git : Download the latest version of the installation package from Git's official website for installation.

  2. Create a new Git repository : You can use the following command to create a new Git repository in the current directory:

    git init
  3. Add files to Git repository : Use  git add commands to add files to the staging area of ​​a Git repository.

    For example, to add all files to the staging area:
    git add .
  4. Submit changes : Use  git commit the command to submit all changes in the temporary storage area to the Git repository.

    For example, submit code and add a description:
    git commit -m "add new feature"
  5. View commit history : Use  git log the command to view the commit history of a Git repository.

    For example, to view the last five commits:
    git log -5
  6. Create and switch branches : use  git branch commands to create or list branches, and use git checkoutcommands to switch to new branches.

    For example, to create a new branch:
    git branch new_feature
    For example, to switch to a new branch:
    git checkout new_feature
  7. Merge Branches : Use  git merge commands to merge content between different branches.

    For example, to merge a new branch into master:
    git merge new_feature
  8. Push to remote warehouse : Use  git push the command to push the changes in the local warehouse to the remote warehouse.

    For example, to push code to a remote repository:
    git push origin main

Guess you like

Origin blog.csdn.net/CLOUDS06/article/details/129869311