Basic Git Commands
Initialize a Repository
Initializes a new Git repository in the current directory.
Clone a Repository
Copies a remote repository to your local machine.
Check Repository Status
Displays the current state of the working directory and staging area.
Add Files to Staging
Stages changes for commit. Use
.to stage all changes.Commit Changes
Saves changes to the repository with a descriptive message.
View Commit History
Shows a list of commits. Use
--onelinefor a compact view.
Branching and Merging
Create a New Branch
Creates a new branch.
Switch to a Branch
Moves to the specified branch.
Create and Switch to a Branch
Creates a new branch and switches to it.
Merge a Branch
Combines changes from the specified branch into the current branch.
Delete a Branch
Deletes a branch (if merged). Use
-Dto force delete.
Remote Repositories
Add a Remote Repository
Links a remote repository.
View Remote Repositories
Lists remote repositories.
Push Changes
Uploads commits to the remote repository.
Pull Changes
Fetches and integrates changes from the remote repository.
Fetch Changes
Downloads changes without merging them.
Undoing Changes
Unstage Changes
Removes a file from the staging area.
Revert a Commit
Creates a new commit to undo changes from a specific commit.
Reset to a Previous Commit
Resets the repository to a specific commit (deletes changes).
Stashing Changes
Stash Changes
Saves uncommitted changes for later.
Apply Stash
Restores stashed changes.
View Stashes
Lists all stashes.
Drop a Stash
Deletes a stash.
Advanced Commands
View Differences
Shows changes between commits, branches, or the working directory.
Tagging a Commit
Adds a tag to a specific commit.
Rebase a Branch
Reapplies commits from one branch onto another.
Squash Commits
Combines multiple commits into one.
Comments
Post a Comment