Skip to content

Latest commit

 

History

History
355 lines (228 loc) · 7.96 KB

github.md

File metadata and controls

355 lines (228 loc) · 7.96 KB

github

run html on github

  • visit http://rawgit.com/
  • 输入你需要执行的 html 网页,会给出两个链接
  • 注意: cdn.rawgit.com 上的文件,第一次访问后会被 永久cache,从而导致 拉取不到最新的文件。
    • 所以一般访问的时候,会指定 某个 commit hash , 或使用最新的 HEAD
    • https://cdn.rawgit.com/mebusy/html5_examples/a12340a5d32b0c760ef138301b067fb1153ef94b/00_marchingSquare.html
    • or https://cdn.rawgit.com/mebusy/html5_examples/HEAD/00_marchingSquare.html

merge specific commit

git cherry-pick [-n] <commit> 
  • -n means no commit

get a file with specific revision

git show REVISION:filePath > outFilePath

git show/diff 乱码问题

git config --global core.quotepath false

OR

git diff | less -r
  • -r means Output "raw" control characters.

[trick] use git log to display the diffs while searching

git log -p -- path/to/file

show files changed between 2 commit

git diff commit1  commit2 --name-only

provide username when clone private repos

git clone https://username[:password]@github.com/username/repository.git

gitlab: git clone leads to "SSL certificate problem: unable to get local issuer certificate"

git config --global http.sslVerify false
git clone ...
git config --global http.sslVerify true

Copy branch from another repository

  1. git clone your repo , so your repo's repo is named origin
  2. add another remote repo , give it name html5
    • git remote add html5 ...
  3. fetch remote repo data
    • git fetch html5
  4. checkout 1 branch html5/develop , to your local branch develop
    • git checkout -b develop html5/develop
  5. push you local branch develop to origin
    • git push --set-upstream origin develop

delete a branch locally and remotely

$ git push --delete <remote_name> <branch_name>
$ git branch -d <branch_name>

delete all tags, local & remote

# delete remote tags before deleting locals
git tag | xargs -L 1 | xargs git push origin --delete

# then delete local tags
git tag | xargs -L 1 | xargs git tag --delete

partial commmit

git commit -p <filename>

handling conflict

Undo a conflict and start over

  • dealing with a merge conflict doesn't necessarily mean you have to resolve it, you can also undo it.
    git merge --abort
    git rebase --abort

submodule conflict

Well, its not technically managing conflicts with submodules (ie: keep this but not that), but I found a way to continue working...and all I had to do was pay attention to my git status output and reset the submodules:

it reset HEAD <sub-module-name>
git commit

Reset Submodule

# reset a specified sub module
$ git submodule update -f <module name>

# reset all sub modules
$ git submodule foreach git reset --hard
# reset all sub modules recursively
$ git submodule foreach --recursive git reset --hard

Cool Git Command

1. git stash

  • save your local modifications away and reverts the working directory to match the HEAD commit.
    • git stash --all
  • Restore saved progress
    • git stash pop

2. git blame

git blame  --color-lines  --color-by-age    -L xxx  path/to/file

-L means Little, it can be a range <start>,<end>, or a function :<funcname>

you can do exactly the same thing with git log

git log -L 40,60:path/to/file

find line copies within and across files in the same commit

git blame -w -C

or the commit that create the file

git blame -w -C -C

or any commit at all

git blame -w -C -C -C

find line movements

git blame -w -M -M -M

3. git log -S

the pickaxe

filter all my git log output to anything that has this regular expression or the string in it

git log -S files_watcher -p

4. git diff

show word based diff instead of lines

git diff --word-diff

example:

reset a [-specified-]{+speci fied+} sub module

5. git maintenance

$ git maintenance start

$tail -3 .git/config
[maintenance]
	auto = false
	strategy = incremental

start background job to

  • gc: disabled
  • commit-graph: hourly
  • prefetch: hourly
  • loose-objects: daily
  • incremental-repack: daily
  • pack-refs: none

Big Repo Stuff

filesystem monitor

git config core.untrackedCache true
git config core.fsmonitor true

partially clone

filter out all blobs (file contents) until needed by Git.

$ git clone --filter=blob:none  #omits all blobs.

or NO trees ( it's relatively rare to use this except for in CI build type stuff)

$ git clone --filter=tree:0