-
Notifications
You must be signed in to change notification settings - Fork 85
/
git
132 lines (108 loc) · 3.34 KB
/
git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# git
git log --oneline
git log --stat --summary
git log -p # see complete diff at each step
git log --author="<pattern>"
git log --grep="<pattern>"
git pull <remote> == git fetch <remote>; git merge origin/<current-branch>
git clean # removes untracked files from working directory
git tag v2.5 1b2ae37b
git grep "hello" v2.5
# revert: the safe way, reset: the dangerous way & permanent undo
# NB. never do reset on published commits
git revert HEAD # revert the most recent commit
git reset # unstages all files without overwriting any changes
git reset --hard # reset the staging area and the working directory to match the most recent commit
git reset --hard <commit> # obliterates all commits after <commit>
git reset --hard HEAD~2 # remove last 2 commits
# delete last commit (assuming i am sitting on that commit) warning you will loose your changes
git reset --hard HEAD~1 or git reset --hard <sha1-commit-id>
# forgot to add files or to make some changes
git add ./path/to/file
git commit -a --amend -C HEAD
# undo last push
git push -f origin HEAD^:master
# fork on github
- sync
git remote add upstream https://github.com/some/project.git
git fetch upstream
git checkout master
git merge --ff-only upstream/master
- create branch and push changes
git checkout -b fix-blah master
git commit -m Fix... core.py
git push origin fix-blah
- keep forked repo synced with upstream
git checkout master
git fetch upstream
git merge --ff-only upstream/master
git rebase upstream/master
git push origin master
- keep pr on top of upstream
https://www.digitalocean.com/community/tutorials/how-to-rebase-and-update-a-pull-request
- delete branch
git branch -d fix-blah
git push -d origin fix-blah
# master/develop/branches (newfeats/bugfixes/releases) http://nvie.com/posts/a-successful-git-branching-model/
* new feature
1. create branch
git checkout -b newfeat develop
2. incorporate feature on develop
git checkout develop
git merge --no-ff myfeat
git branch -d myfeat
git push origin develop
3. create a release branch
git checkout -b release-1.2 develop
change version number
git commit -a -m 'New release 1.2'
4. finishing a release branch
git checkout master
git merge --no-ff release-1.2
git tag -a 1.2
git checkout develop
git merge --no-ff release-1.2
git branch -d release-1.2
* new hotfix
git checkout -b hotfix-1.2.1 master
change version number
git commit -a -m 'New bugfix version 1.2.1'
fix bug
git commit -m 'Fixed blah bug'
git checkout master
git merge --no-ff hotfix-1.2.1
git tag -a 1.2.1
git checkout develop
git merge --no-ff hotfix-1.2.1
git branch -d hotfix-1.2.1
# stash
git stash list
git stash apply stash@{2}
git stash show
# making changes to pull request
git fetch https://github.com/asolino/patator master
git checkout FETCH_HEAD
make changes
git add patator.py
git commit -a
git checkout master
git merge <commitid of my commit above>
git push
# skiddit
git checkout -b release-0.3 master
change version number
git commit -a -m 'New release 0.3'
git checkout master
git merge --no-ff release-0.3
git tag -a 0.3
enter release-0.3
git branch -d release-0.3
git push origin --tags
git push
# cat all objects to grep for flag
for i in .git/objects/*/*; do j=${i#.git/objects/}; j=$(echo $j | tr -d /); echo $j; git cat-file -p $j; done | grep flag
# rip .git
http://www.slideshare.net/kost/ripping-web-accessible-git-files
tools/exploit/dvcs-rippers
# gui
gitk, qgit, tig