0% found this document useful (0 votes)
55 views1 page

Git Commands

Git is a version control system that allows tracking changes to files. It has many commands for initializing repositories, tracking changes, and collaborating remotely. Some key commands include git init to start a local repository, git add to stage files for committing, and git commit to save changes locally with a message. Other commands control branching, merging, pushing and pulling changes from remote repositories.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Git Commands

Git is a version control system that allows tracking changes to files. It has many commands for initializing repositories, tracking changes, and collaborating remotely. Some key commands include git init to start a local repository, git add to stage files for committing, and git commit to save changes locally with a message. Other commands control branching, merging, pushing and pulling changes from remote repositories.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

GIT COMMANDS

git init: Initializes a new Git repository in the current directory.

git clone [url]: Clones a repository into a newly created directory.

git add [file]: Adds a file to the staging area. You can also use git add . to add
all files.

git commit -m "[message]": Commits changes to the repository with a descriptive


message.

git status: Shows the status of changes in the working directory and staging area.

git diff: Shows the differences between the working directory and the staging area.

git diff --staged: Shows the differences between the staging area and the last
commit.

git log: Displays a log of commits.

git branch: Lists all local branches. Use -r to see remote branches and -a to see
all branches.

git branch [branch-name]: Creates a new branch.

git checkout [branch-name]: Switches to the specified branch.

git checkout -b [branch-name]: Creates a new branch and switches to it.

git merge [branch-name]: Merges the specified branch into the current branch.

git remote -v: Lists all remote repositories.

git remote add [name] [url]: Adds a new remote repository.

git push [remote] [branch]: Pushes commits from your local repository to a remote
repository.

git pull [remote] [branch]: Fetches changes from a remote repository and merges
them into the current branch.

git fetch [remote]: Fetches changes from a remote repository.

git reset [file]: Unstages the file, but leaves its contents unchanged.

git reset --hard: Resets the staging area and working directory to match the most
recent commit.

git rm [file]: Removes a file from the working directory and stages the deletion.

git mv [existing-file] [new-file]: Renames a file and stages the change.

These are just some of the most commonly used Git commands. Git has a wide range of
commands and options for various workflows and scenarios. You can find more
detailed information in the Git documentation or by using git help followed by the
command you're interested in.

You might also like