Git commands you should know:
-
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 add [file]: Stages changes for commit. You can use
git add .
to stage all changes. -
git commit -m “Commit message”: Commits the staged changes with a descriptive message.
-
git status: Shows the current status of your working directory, including staged and unstaged changes.
-
git log: Displays a log of all commits, including their hashes, authors, dates, and commit messages.
-
git branch: Lists all branches in your repository, highlighting the current branch.
-
git checkout [branch_name]: Switches to a different branch. You can also use it to create new branches with
-b
. -
git merge [branch_name]: Merges changes from the specified branch into the current branch.
-
git pull: Fetches changes from a remote repository and merges them into your current branch.
-
git push: Pushes your local changes to a remote repository.
-
git remote -v: Lists all remote repositories associated with your project.
-
git fetch: Fetches changes from a remote repository without automatically merging them.
-
git reset [commit]: Unstages changes, or moves the HEAD to a specific commit.
-
git stash: Temporarily saves changes that are not ready to be committed.
-
git tag [tag_name]: Creates a lightweight tag for a specific commit.
-
git diff: Shows the difference between your working directory and the last commit.
-
git blame [file]: Shows who last modified each line of a file and when.
-
git remote add [remote_name] [remote_url]: Adds a new remote repository.
-
git remote remove [remote_name]: Removes a remote repository.
0 Comments