git init
git init
Initializes a new Git repository in the current directory. This
creates a hidden .git folder that tracks all version
history and configuration for your project.
git clone
git clone <repository-url>
Creates a local copy of an existing remote repository. Downloads all
files, history, and branches from the specified URL.
git add
git add <file>
Stages changes in the specified file, preparing them to be
committed. The file will be included in the next commit.
git add .
Stages all modified and new files in the current directory and its
subdirectories for the next commit.
git commit
git commit -m "Your commit message"
Records the staged changes to the repository with a descriptive
message. Each commit creates a unique snapshot of your project.
git status
git status
Displays the current state of the working directory and staging
area. Shows which files are modified, staged, or untracked.
git push
git push <remote> <branch>
Uploads local commits from the specified branch to a remote
repository, making your changes available to others.
git pull
git pull <remote> <branch>
Fetches new commits from the specified remote branch and merges them
into your current branch, updating your local repository.
git branch
git branch
Lists all local branches in the repository. The current branch is
highlighted with an asterisk.
git checkout
git checkout <branch>
Switches to the specified branch, updating the working directory to
match its state.
git checkout -b <branch>
Creates a new branch with the given name and immediately switches to
it.
git merge
git merge <branch>
Integrates changes from the specified branch into the current
branch, combining their histories.
git log
git log
Shows the commit history for the repository, including commit
hashes, authors, dates, and messages.
git log --oneline
Displays the commit history in a condensed, one-line-per-commit
format for easier reading.
git remote
git remote -v
Lists the short names and URLs of remote repositories connected to
your local repository, showing where you can push or pull code.