-
git init
: Initializes a new Git repository in the current directory.
-
git clone [repository URL]
: Makes a copy of an existing Git repository to your local machine.
-
git add [file/folder]
: Adds changes to the staging area before committing them.
-
git commit -m "message"
: Commits changes to the local repository with a descriptive message.
-
git status
: Shows the current status of the repository, including any changes that have been made.
-
git log
: Displays a log of all commits made to the repository.
-
git branch
: Lists all branches in the repository.
-
git checkout [branch name]
: Switches to a different branch in the repository.
-
git merge [branch name]
: Merges changes from one branch into another.
-
git pull
: Fetches changes from the remote repository and merges them into the local repository.
-
git push
: Uploads changes from the local repository to the remote repository.
-
git remote add [name] [URL]
: Adds a new remote repository to the local repository.
-
git remote -v
: Lists all remote repositories connected to the local repository.
-
git diff
: Shows the differences between the local repository and the staging area or working directory.
-
git reset
: Resets changes made to the repository, removing them from the staging area.
-
git rm [file]
: Removes a file from the repository.
-
git mv [old file name] [new file name]
: Renames a file in the repository.
-
git tag [tag name]
: Creates a new tag for a specific commit.
-
git fetch
: Downloads changes from the remote repository without merging them into the local repository.
-
git stash
: Saves changes made to the working directory for later use.
-
git pull --rebase
: Fetches changes from the remote repository and rebases them onto the local branch.
-
git blame [file]
: Shows who made each change to a specific file and when they made it.
-
git cherry-pick [commit]
: Applies changes from a specific commit to the current branch.
-
git revert [commit]
: Reverts changes made in a specific commit and creates a new commit to undo them.
-
git show [commit]
: Shows details about a specific commit, including its message and changes.
-
git branch -d [branch name]
: Deletes a branch from the repository.
-
git branch -m [old branch name] [new branch name]
: Renames a branch in the repository.
-
git push -u [remote name] [branch name]
: Sets the default upstream branch for a local branch.
-
git checkout -b [new branch name]
: Creates a new branch and switches to it.
-
git log --oneline
: Displays a short log of all commits made to the repository.
-
git log --graph
: Displays a graphical representation of the commit history.
-
git merge --abort
: Aborts a merge that is currently in progress.
-
git commit --amend
: Adds changes to the previous commit instead of creating a new one.
-
git config --global user.name "[name]"
: Sets the name associated with Git commits.
-
git config --global user.email "[email address]"
: Sets the email associated with Git commits.
-
git config --global color.ui true
: Enables colored output in Git commands.
-
git stash pop
: Applies the most recent stash to the working directory.
-
git clean
: Removes untracked files from the working directory.
-
git remote rm [remote name]
: Removes a remote repository from the local repository.
-
git diff HEAD
: Shows the differences between the local repository and the last commit.
-
git reset --hard
: Resets all changes made to the repository, removing them from the working directory.
-
git reset --soft [commit]
: Resets the repository to a specific commit but keeps the changes in the staging area.
-
git pull --rebase origin [branch name]
: Fetches changes from the remote repository and rebases them onto the local branch.
-
git config --list
: Lists all Git configuration settings.
-
git show-branch
: Displays a graphical representation of the relationship between different branches.
-
git bisect start
: Starts a binary search to find a bug in the repository's history.
-
git bisect good
: Marks a commit as good during a binary search.
-
git bisect bad
: Marks a commit as bad during a binary search.