-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathtips.json
More file actions
259 lines (259 loc) · 7.73 KB
/
tips.json
File metadata and controls
259 lines (259 loc) · 7.73 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
[
{
"title": "Overwrite pull",
"tip": "git fetch --all && git reset --hard origin/master"
},
{
"title": "List of all files till a commit",
"tip": "git ls-tree --name-only -r <commit-ish>"
},
{
"title": "Git reset first commit",
"tip": "git update-ref -d HEAD"
},
{
"title": "List all the conflicted files",
"tip": "git diff --name-only --diff-filter=U"
},
{
"title": "List of all files changed in a commit",
"tip": "git diff-tree --no-commit-id --name-only -r <commit-ish>"
},
{
"title":"Unstaged changes since last commit",
"tip":"git diff"
},
{
"title":"Changes staged for commit",
"tip":"git diff --cached"
},
{
"title":"Show both staged and unstaged changes",
"tip":"git diff HEAD"
},
{
"title": "List all branches that are already merged into master",
"tip": "git checkout master && git branch --merged"
},
{
"title": "Quickly switch to the previous branch",
"tip": "git checkout -"
},
{
"title": "Remove branches that have already been merged with master",
"tip": "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
},
{
"title": "List all branches and their upstreams, as well as last commit on branch",
"tip": "git branch -vv"
},
{
"title": "Track upstream branch",
"tip": "git branch -u origin/mybranch"
},
{
"title": "Delete local branch",
"tip": "git branch -d <local_branchname>"
},
{
"title": "Delete remote branch",
"tip": "git push origin --delete <remote_branchname>",
"alternatives": ["git push origin :<remote_branchname>"]
},
{
"title": "Undo local changes with the last content in head",
"tip": "git checkout -- <file_name>"
},
{
"title":"Revert: Undo a commit by creating a new commit",
"tip":"git revert <commit-ish>"
},
{
"title":"Reset: Discard commits, advised for private branch",
"tip":"git reset <commit-ish>"
},
{
"title": "Reword the previous commit message",
"tip": "git commit -v --amend"
},
{
"title": "Changing a remote's URL",
"tip": "git remote set-url origin <URL>"
},
{
"title": "Get list of all remote references",
"tip": "git remote",
"alternatives": ["git remote show"]
},
{
"title": "Get list of all local and remote branches",
"tip": "git branch -a"
},
{
"title": "Get only remote branches",
"tip": "git branch -r"
},
{
"title": "Stage parts of a changed file, instead of the entire file",
"tip": "git add -p"
},
{
"title": "Get git bash completion",
"tip": "curl http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc"
},
{
"title": "What changed since two weeks?",
"tip": "git whatchanged --since='2 weeks ago'"
},
{
"title": "See all commits made since forking from master",
"tip": "git log --no-merges --stat --reverse master.."
},
{
"title": "Pick commits across branches using cherry-pick",
"tip": "git checkout <branch-name> && cherry-pick <commit-ish>"
},
{
"title": "Find out branches containing commit-hash",
"tip": "git branch -a --contains <commit-ish>",
"alternatives": ["git branch --contains <commit-ish>"]
},
{
"title": "Git Aliases",
"tip": "git config --global alias.<handle> <command> \ngit config --global alias.st status"
},
{
"title":"Saving current state of tracked files without commiting",
"tip": "git stash",
"alternatives": ["git stash save"]
},
{
"title":"Saving current state including untracked files",
"tip": "git stash save -u",
"alternatives": ["git stash save --include-untracked"]
},
{
"title":"Show list of all saved stashes",
"tip": "git stash list"
},
{
"title": "Apply any stash without deleting from the stashed list",
"tip": "git stash apply <stash@{n}>"
},
{
"title":"Apply last stashed state and delete it from stashed list",
"tip": "git stash pop",
"alternatives": ["git stash apply stash@{0} && git stash drop stash@{0}"]
},
{
"title": "Delete all stored stashes",
"tip": "git stash clear",
"alternatives": ["git stash drop <stash@{n}>"]
},
{
"title":"Show all tracked files",
"tip":"git ls-files -t"
},
{
"title":"Show all untracked files",
"tip":"git ls-files --others"
},
{
"title": "Show all ignored files",
"tip": "git ls-files --others -i --exclude-standard"
},
{
"title": "Create new working tree from a repository (git 2.5)",
"tip":"git worktree add -b <branch-name> <path> <start-point>"
},
{
"title": "Create new working tree from HEAD state",
"tip": "git worktree add --detach <path> HEAD"
},
{
"title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories",
"tip": "git clean -n"
},
{
"title": "Forcefully remove untracked files",
"tip": "git clean -f"
},
{
"title": "Forcefully remove untracked directory",
"tip": "git clean -f -d",
"alternatives": ["git clean -df"]
},
{
"title": "Update all the submodules",
"tip": "git submodule foreach git pull"
},
{
"title": "Show all commits in the current branch yet to be merged to master",
"tip": "git cherry -v master",
"alternatives": ["git cherry -v master <branch-to-be-merged>"]
},
{
"title": "Rename a branch",
"tip": "git branch -m <new-branch-name>",
"alternatives": ["git branch -m [<old-branch-name>] <new-branch-name>"]
},
{
"title": "rebases 'feature' to 'master' and merges it in to master ",
"tip": "git checkout feature && git rebase @{-1} && git checkout @{-2} && git merge @{-1}"
},
{
"title": "Archive the `master` branch",
"tip": "git archive master --format=zip --output=master.zip"
},
{
"title": "Modify previous commit without modifying the commit message",
"tip": "git add --all && git commit --amend --no-edit"
},
{
"title": "Prunes branches that have been deleted in the remote.",
"tip": "git fetch -p",
"alternatives":["git remote prune origin"]
},
{
"title": "Retrieve the commit hash of the initial revision.",
"tip": " git rev-list --reverse HEAD | head -1"
},
{
"title": "Visualize the version tree.",
"tip": "git log --pretty=oneline --graph --decorate --all",
"alternatives":["gitk --all"]
},
{
"title": "Deploying git tracked subfolder to gh-pages",
"tip": "git subtree push --prefix subfolder_name origin gh-pages",
"alternatives": "git subtree push --prefix subfolder_name origin branch_name"
},
{
"title": "Adding a project to repo using subtree",
"tip": "git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master"
},
{
"title": "Get latest changes in your repo for a linked project using subtree",
"tip": "git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master"
},
{
"title": "Export a branch with history to the a file.",
"tip": "git bundle create <file> <branch-name>"
},
{
"title": "Import form a bundle",
"tip": "git clone repo.bundle <repo-dir> -b <branch-name>"
},
{
"title": "Get the name of current branch.",
"tip": "git rev-parse --abbrev-ref HEAD"
},
{
"title": "Ignore one file on commit (e.g. Changelog).",
"tip": "git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog"
},
{
"title": "Visualize each position of HEAD in the last 30 days",
"tip": "git reflog"
}
]