Git Commands Cheat Sheet

ADVERTISEMENT

Repo
Repo to User
Repo Info
G I T C O M M A N D S
C � e a � S � � e �
Repo
User to Repo
Branch Control
git
add .
OR
git
add
-A
git
add
<file name>
git
add
--all
OR
OR
This is how you add changes to staging before you commit them. This step may not be
Repo
neccessary depending on how you are committing your changes.
git
branch
If you want to see all the available branches on your repository, use
git
branch. This will print
a list of all the branches on your repo.
git
checkout
<branch name>
OR
git
checkout
-b <new branch name>
Git checkout <branch name>
will move you the branch you specified. Your changes will
now also be pushed to the new branch. If you want to create a new branch, you can use
git
checkout -b <new branch
name>. Doing this will also put you onto the new branch.
git
clone
<repo address>
OR
git
clone
<repo address>:<directory>
This is how you will get started on an existing repository. You can find the repo address in
Repo
GitHub under the the repository’s main page under
“clone or
download”. For bitbucket it is
under the “Overview” tab next to the
HTTPS/SSH
drop down. The address will look like
“git@bitbucket.org:optimalbi/<repo name>” for SSH or
name>” for HTTPS. Both sites support HTTPS/SSH. To
clone to a specific directory add “:<directory-name>” to the end of the command.
git
commit
-m “message”
OR
git
commit
OR
git
commit
-a
git
commit
--all
OR
Use this before you bush. The best option for a beginner is
git commit -m
“message”. Simply
Repo
using
git commit
will open the default text editor which can be difficult to use as a beginner.
Using
git commit -a
or
git commit --all
will automatically add all modified files to staging but
this will also open a text editor.
git
init
THEN
git
remote add origin
<repo address>
If you ave files on your local machine and you think ‘hey, I should add this to git’,
git init
is
Repo
the answer. Simple
git
log
This will give you a print out of all the previous commit messages on your branch. This is
great for catching up on what has happened in a project.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2