git init: Initializes a new Git repository in the current directory.
git clone <repository-url>: Creates a copy of a remote repository on your local machine.
$ git clone https://github.com/exampleuser/my-repo.git
git add <file>: Adds a file to the staging area, preparing it for the next commit.
git add . or
git add --all: Adds all modified and new files in the current directory and its subdirectories to the staging area.
git commit -m "Commit message": Commits the changes in the staging area to the repository with a descriptive message.
$ git commit -m "Added new feature"
git status: Shows the status of your working directory, including which files are modified, staged, or untracked.
git log: Displays the commit history, showing the latest commits first.
git branch: Lists all branches in the repository, with an asterisk indicating the currently active branch.
git checkout <branch-name>: Switches to the specified branch.
$ git checkout development
git checkout -b <new-branch-name>: Creates and switches to a new branch.
$ git checkout -b feature-branch
git pull: Fetches and merges changes from the remote repository into the current branch.
git push: Pushes committed changes from the local repository to the remote repository.
git merge <branch-name>: Merges the specified branch into the currently active branch.
$ git merge feature-branch
git remote add <remote-name> <remote-url>: Adds a remote repository with a given name and URL.
$ git remote add upstream https://github.com/upstream-repo/original-repo.git
git remote -v: Lists the remote repositories associated with your local repository.
git fetch <remote-name>: Fetches changes from a remote repository without automatically merging them.
git diff: Shows the differences between the working directory and the staging area.
git diff --staged: Shows the differences between the staged changes and the last commit.
git reset <file>: Removes a file from the staging area without undoing the changes.
git reset --hard: Discards all changes in the working directory and resets it to the last commit.