Skip to content

Commit d0a0bc8

Browse files
author
Cormac O'Mahony
committed
Added git commands.
0 parents  commit d0a0bc8

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Git Commands.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Git Commands
2+
3+
## Remove all your local git branches but keep master
4+
git branch | grep -v "master" | xargs git branch -D
5+
6+
## Create a new branch BASED ON THE CURRENT BRANCH
7+
git checkout -b <newBranch>
8+
9+
## Undo all local pending changes
10+
git reset HEAD --hard
11+
12+
## Undo a single file change
13+
git checkout -- <fileName>
14+
15+
## Push new branch to server
16+
git push origin <branchName>
17+
18+
## Delete remote branch
19+
git push origin --delete <branchName>
20+
21+
## List all local and remote branches
22+
git branch -a
23+
24+
## Remove deleted branches
25+
git remote prune origin
26+
27+
## Pull remote master branch and merge it into current branch
28+
git pull origin master
29+
30+
## Undo last commit but keep files (before it's pushed)
31+
git reset HEAD~1
32+
33+
## Rename current branch to new name
34+
git branch -m <newname>
35+
36+
## Save temporarily your changes so you can check out another branch
37+
git stash
38+
39+
## List temporary saves
40+
git stash list
41+
42+
## Get back changes from a temporary save
43+
git stash apply
44+
45+
## Delete temporary saves
46+
git stash drop
47+
48+
## Rename local branch
49+
git branch -m <newname>
50+
51+
## Amend Your Last Commit
52+
git commit --amend
53+
54+
## See Changed Files Between Branches
55+
git diff --name-only <branch>

0 commit comments

Comments
 (0)