The Main Git Commands
Git is a distributed version control system.
Version Control System: Tracks all changes to files over time.
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.
The Main Git Commands