Welcome to the Git basic tutorial! This guide will help you get started with Git, a powerful version control system. Whether you are a beginner or an experienced developer, understanding Git is essential for efficient collaboration and code management.

快速入门

  1. 安装 Git
    Before you start, make sure you have Git installed on your system. You can download and install it from the official Git website.

  2. 初始化仓库
    Once installed, open your terminal and navigate to the directory where you want to create your repository. Then, run the following command to initialize a new Git repository:

    git init
    
  3. 添加文件
    Now, add a file to your repository. For example, create a file named README.md and add some content to it. Then, run the following command to stage the file for commit:

    git add README.md
    
  4. 提交更改
    Finally, commit your changes to the repository. Run the following command:

    git commit -m "Initial commit"
    

常用命令

Here are some of the most commonly used Git commands:

  • git add <file>: Stage a file for commit.
  • git commit: Commit staged changes to the repository.
  • git push: Push your local commits to a remote repository.
  • git pull: Fetch and merge changes from a remote repository into your local repository.

图片示例

Here's an example of a Git commit:

commit 1f9e5d7 (HEAD -> main)
Author: Your Name <your_email@example.com>
Date:   Mon Mar 14 14:00:00 2022 +0800

    Add README.md

[

Git Commit
]

扩展阅读

If you want to dive deeper into Git, we recommend checking out our comprehensive Git 教程 for more advanced topics.