@@ -232,11 +232,6 @@ git ls-files --others
232
232
git ls-files --others -i --exclude-standard
233
233
```
234
234
235
- ## Create new working tree from HEAD state
236
- ``` sh
237
- git worktree add --detach < path> HEAD
238
- ```
239
-
240
235
## 强制删除untracked的文件
241
236
清空工作区untracked的文件
242
237
``` sh
@@ -254,62 +249,22 @@ git clean -df
254
249
git branch -m < new-branch-name>
255
250
```
256
251
257
- ## Modify previous commit without modifying the commit message
258
- ``` sh
259
- git add --all && git commit --amend --no-edit
260
- ```
261
-
262
- ## Prunes references to remote branches that have been deleted in the remote.
263
- ``` sh
264
- git fetch -p
265
- ```
266
-
267
-
268
- __ Alternatives:__
269
- ``` sh
270
- git remote prune origin
271
- ```
272
-
273
- ## Retrieve the commit hash of the initial revision.
274
- ``` sh
275
- git rev-list --reverse HEAD | head -1
276
- ```
277
-
278
252
## 展示简化的commit历史
279
253
``` sh
280
254
git log --pretty=oneline --graph --decorate --all
281
255
```
282
256
283
- ## Deploying git tracked subfolder to gh-pages
284
- ``` sh
285
- git subtree push --prefix subfolder_name origin gh-pages
286
- ```
287
-
288
- ## Adding a project to repo using subtree
289
- ``` sh
290
- git subtree add --prefix=< directory_name> /< project_name> --squash git@github.com:< username> /< project_name> .git master
291
- ```
292
-
293
- ## Get latest changes in your repo for a linked project using subtree
294
- ``` sh
295
- git subtree pull --prefix=< directory_name> /< project_name> --squash git@github.com:< username> /< project_name> .git master
296
- ```
297
-
298
- ## Export a branch with history to a file.
257
+ ## 把某一个分支到导出成一个文件
299
258
``` sh
300
259
git bundle create < file> < branch-name>
301
260
```
302
261
303
- ## Import from a bundle
262
+ ## 从包中导入分支
263
+ 新建一个分支,分支内容就是上面` git bundle create ` 命令导出的内容
304
264
``` sh
305
265
git clone repo.bundle < repo-dir> -b < branch-name>
306
266
```
307
267
308
- ## Get the name of current branch.
309
- ``` sh
310
- git rev-parse --abbrev-ref HEAD
311
- ```
312
-
313
268
## Ignore one file on commit (e.g. Changelog).
314
269
``` sh
315
270
git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog
@@ -366,51 +321,11 @@ git checkout <deleting_commit>^ -- <file_path>
366
321
git checkout < commit-ish> -- < file_path>
367
322
```
368
323
369
- ## Always rebase instead of merge on pull.
370
- ``` sh
371
- git config --global branch.autosetuprebase always
372
- ```
373
-
374
324
## 展示所有alias和configs.
375
325
``` sh
376
326
git config --list
377
327
```
378
328
379
- ## Make git case sensitive.
380
- ``` sh
381
- git config --global core.ignorecase false
382
- ```
383
-
384
- ## Add custom editors.
385
- ``` sh
386
- git config --global core.editor ' $EDITOR'
387
- ```
388
-
389
- ## Check if the change was a part of a release.
390
- ``` sh
391
- git name-rev --name-only < SHA-1>
392
- ```
393
-
394
- ## Dry run. (any command that supports dry-run flag should do.)
395
- ``` sh
396
- git clean -fd --dry-run
397
- ```
398
-
399
- ## Marks your commit as a fix of a previous commit.
400
- ``` sh
401
- git commit --fixup < SHA-1>
402
- ```
403
-
404
- ## squash fixup commits normal commits.
405
- ``` sh
406
- git rebase -i --autosquash
407
- ```
408
-
409
- ## skip staging area during commit.
410
- ``` sh
411
- git commit --only < file_path>
412
- ```
413
-
414
329
## 展示忽略的文件
415
330
``` sh
416
331
git status --ignored
0 commit comments