Git Command Reference
Git Command Reference
1. Cloning a Repository
● Purpose: To create a local copy of a remote repository (e.g., from GitHub).
● Command:
git clone <repository_url>
● Example:
git clone https://github.com/yourusername/your-repo.git
● Example:
cd Desktop/my-project
● Example Output:
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: TimurDesign/agent.sv
no changes added to commit (use "git add" and/or "git commit -a")
4. Staging Changes
● Purpose: To add changes to the staging area (index), preparing them for the next
commit.
● Command:
○ Stage a specific file:
git add <filename>
● Examples:
git add TimurDesign/agent.sv
git add README.md
git add .
5. Committing Changes
● Purpose: To create a snapshot of the staged changes in the local repository's
history.
● Command:
git commit -m "Commit message describing the changes"
● Example:
git commit -m "Added new feature to agent.sv"
git commit -m "Fixed bug in user authentication"
6. Pushing Changes
● Purpose: To upload local commits to the remote repository (e.g., GitHub).
● Command:
git push <remote_name> <branch_name>
● Example:
git push origin main
● Examples:
○ Basic log:
git log
8. Understanding Branches
● Purpose: To create parallel versions of your project for feature development, bug
fixes, and experimentation.
● Analogy: Think of branches as separate timelines or "universes" of your project.
● Main Branch: The primary branch (usually main), representing the stable version
of your code.
● Feature Branch: A branch created to develop a specific feature.
● Bug Fix Branch: A branch created to fix a bug.
● Command to create a branch:
git branch <new_branch_name>