The Main Git Commands

source: https://docs.google.com/presentation/d/1QxwuDlUkM4crQfZsZ1prhJGfqjPBAbVa-ifKsZHqCLU/edit#slide=id.g265c577d76c_0_305

Git is a distributed version control system.

  1. Version Control System: Tracks all changes to files over time.

  2. Distributed: Every developer’s computer stores the entire history of the project. The entire history of a project is called a repository.

Github is Git(hub).

The Main Git Commands

git init: Initializes a git repository in current directory.

git add <file_name>: Adds a file to staging (to be committed).

git commit -m “Message”: Saves all staged files into a commit (like a snapshot of your current repository)

git status: Displays state of the repository and staging area (tracked, untracked files and changes).

git log: Displays the history of our committed history.

git restore: Restores files to their versions in the most recent commit.

git restore --source=[commitID]: Restores files to their versions in the given commit.

git push <repo> <branch>: Takes commits on your local computer and pushes it into the remote repository.

git pull <repo> <branch>: Pulls any changes from the remote repository onto your computer.

20241121145138

作者

Zylll

发布于

2024-11-21

更新于

2024-11-23

许可协议