Git Commands Cheat Sheet Page 2

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
merge
<branch name>
If you want the changes on another branch added to your branch, e.g. chages in
‘feature’would be useful in ‘develop’, use
git merge <branch
name>. In this scenario we
would be on ‘develop’ and use
git merge feature
git
pull
This will pull all the new commits from the remote repo to your local repo i.e. when someone
Repo
pushes a change to the remote repo, you will have to pull it down to your local before you
can see it.
git
push
-u origin <branch>
OR
git
push
Before you can use git push, you need to tell git where you want to push to. To do this, we
Repo
need to use
git push -u origin <branchname>
for the first push we do. This tells git that your
branch is the same as the remote branch. Because you use the
-u
flag, you will only need to
do this once. Now you can just use
git
push.
git
push -d origin
<branch_name>
THEN
git
branch -d
<branch_name>
This is the command to delete a branch. Make sure you want to delete the branch as well as
making sure you spell the branch name correctly.
git
stash
save "description of changes"
If you have uncommitted changes that you would like to get rid of,
git stash "description of
changes"
is what you will use. This will get rid of the changes off your branch but will also
stash them if you change you mind later. You can add a message to your stash so when you
use
git stash list
later, you know what is what. If your stashes become crowded, use
git stash
clear
to remove all stashes,
git stash drop
to remove the most recent, and
git stash drop
stash@{n}
where n nominates the stash reference to drop.
status
git
Use this to check the status of your branch. This will show you what files you have modified,
staged, or unstaged.
Resources
Here are some resources for finding out more.
https://goo.gl/kjk8hx
- A great interactive troubleshooter for when you get stuck.
https://goo.gl/ZxH7QU
- A glossary of Git commands.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2