Don't Forget to ⭐ Star This Repository!
- Function: Initializes a Git repository in the local directory.
- Example:
git init
- Explanation: Creates a new Git repository in the current directory.
- Function: Downloads a repository from a remote source.
- Example:
git clone https://github.com/username/repo.git
- Explanation: Copies a repository from remote to local.
- Function: Adds changes to the staging area.
- Example:
git add .
orgit add <file>
- Explanation: Prepares files to be committed.
- Function: Saves a snapshot of the staging area.
- Example:
git commit -m "Initial commit"
- Explanation: Commits the changes with a descriptive message.
- Function: Displays the status of files in the repository.
- Example:
git status
- Explanation: Shows modified, staged, or untracked files.
- Function: Sends commits to the remote repository.
- Example:
git push origin main
- Explanation: Synchronizes the local branch with the remote.
- Function: Fetches and merges changes from remote.
- Example:
git pull origin main
- Explanation: Updates the local branch from the remote.
- Function: Lists or creates branches.
- Example:
git branch
orgit branch new-feature
- Explanation: Manages development branches.
- Function: Switches between branches or specific commits.
- Example:
git checkout main
orgit checkout <commit>
- Explanation: Navigates between branches or repository states.
- Function: Merges another branch into the current branch.
- Example:
git merge new-feature
- Explanation: Integrates changes from a different branch.
- Function: Views commit history.
- Example:
git log
- Explanation: Displays a list of all commits.
- Function: Reverses the changes of a specific commit.
- Example:
git revert <hash_commit>
- Explanation: Creates a new commit that undoes the specified commit.
- Function: Resets the repository to a previous commit.
- Example:
git reset --hard <commit>
- Explanation: Moves the branch pointer to a previous commit (can discard changes).
- Function: Temporarily stores working directory changes.
- Example:
git stash
- Explanation: Saves uncommitted changes to be reapplied later with
git stash pop
.