Keep it simple and cool.
noscripter / noscripter.github.io Goto Github PK
View Code? Open in Web Editor NEWKeep it simple and stupid.
License: Creative Commons Zero v1.0 Universal
Keep it simple and stupid.
License: Creative Commons Zero v1.0 Universal
Keep it simple and cool.
git remote set-branches origin '*'
before:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/ReactiveX/rxjs
fetch = +refs/heads/master:refs/remotes/origin/master
[branch "master"]
remote = origin
merge = refs/heads/master
after:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/ReactiveX/rxjs
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
git fetch -v
本地回退到某次提交:
git checkout xxx-commit-hash
远程分支回退到某次提交:
git reset --hard xxx-commit-hash
跟着上面的命令,先将工作目录回退到某次提交,然后执行下面的命令:
git push -f origin xxx分支
git commit --amend -m 'xxxx'
git push remote branch --force # 或者 git push remote branch -f
git push origin :<branchName>
git diff branch1 branch2 xxx_file
git diff --name-status branch1 branch2
或者:
git diff --stat --color branch1 branch2
git branch -ar
git ls-remote
git remote show origin
有时候本地的远程信息没有同步,需要执行下面的命令同步:
git remote update
git config --list
或者:
git config -l
查看所有配置信息:
git config --get-all user.name
或者:
git config user.name
查看某个值的内容:
git config --global -l
查看全局配置
/etc/gitconfig
~/.gitconfig
git config --local user.name 'xxxx'
git config --local user.email '[email protected]'
也可以通过修改.git/config
下的信息来修改当前仓库的git信息。
git config --local -l
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
git reset --hard HEAD~1 #撤销最近一次commit,即从HEAD恢复到上一次commit
git log -G"正则表达式"
例如:git log -G"preswitch"
<http://alblue.bandlem.com/2011/08/git-tip-of-week-searching-for-commits.html http://gitref.org/inspect/>
git log -Spreswitch
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_NAME" = "noscripter" ];
then
GIT_AUTHOR_NAME="anonymous";
GIT_AUTHOR_EMAIL="[email protected]";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
http://stackoverflow.com/questions/750172/change-the-author-of-a-commit-in-git
git filter-branch --env-filter '
oldname="(old name)"
oldemail="(old email)"
newname="(new name)"
newemail="(new email)"
[ "$GIT_AUTHOR_EMAIL" = "$oldemail" ] && GIT_AUTHOR_EMAIL="$newemail"
[ "$GIT_COMMITTER_EMAIL" = "$oldemail" ] && GIT_COMMITTER_EMAIL="$newemail"
[ "$GIT_AUTHOR_NAME" = "$oldname" ] && GIT_AUTHOR_NAME="$newname"
[ "$GIT_COMMITTER_NAME" = "$oldname" ] && GIT_COMMITTER_NAME="$newname"
' HEAD
rm -rf .git
git init
git add .
git commit -m "Initial commit"
git remote add origin
git push -u --force origin master
修改.git/config
中的origin
信息,将https
协议改为[email protected]:xxx/project-name
。
或者使用git remote set-url origin [email protected]:username/repo.git
ssh -vT [email protected]
错误信息为:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决方法:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-add -l
注意,上面第二步ssh-add加入的是密钥,而不是公钥。
如果ssh-add -l
运行后显示The agent has no identities.
说明没有把公钥加入到ssh客户端中。
参考链接:
git diff --relative=[path]
git diff --stat
http://usevim.com/2012/03/21/git-and-vimdiff/
git diff --patience
https://stackoverflow.com/questions/4045017/what-is-git-diff-patience-for
git diff mybranch master -- myfile.cs
git rev-parse --show-toplevel
其他
例如:
svn checkout https://github.com/flazz/vim-colorschemes/trunk/colors/
其中trunk
对应github的master
分支。
git commit --amend --author="Author Name <[email protected]>"
git status --ignored
git add --force folder
git diff --stat --cached [remote/branch]
git diff [remote repo/branch]
git diff --numstat [remote repo/branch]
git push --dry-run
git reset --hard [remote branch]
git ignore
核心文件git config --global core.excludesfile '~/.gitignore'
首先在~/.gitconfig
中配置如下alias
:
[alias]
url =! bash -c 'git config --get remote.origin.url | sed -E "s/.+:\\(.+\\)\\.git$/https:\\\\/\\\\/github\\\\.com\\\\/\\\\1/g"'
这样使用git url
就可以看到仓库的http地址了。
打开的话就只需要执行git url | xargs open或者:
open `git url`
即可。
fatal: Could not open file .git/rebase-merge/done for reading: No such file or directory
git rebase --abort
未提交:
git commit --amend -m'xxxx'
已提交:
git rebase -i HEAD~n
git push --force
.git
目录git cat-file -p xxxhashvalue
.git/objects
目录保存了每次commit的信息 .git/refs
目录保存了仓库的分支信息
Git is essentially a simple key-value data store.
find .git/objects -type f echo 'test content' | git hash-object -w --stdin git cat-file -p xxxxhashvalue
git log --pretty=format:"[%h] %ae, %ar: %s" --stat
其中格式字符串的含义分别为:%h
表示提交记录的 hash 值;%ae
表示提交者的邮箱信息;%ar
表示提交时间;%s
表示提交日志信息。 git log
格式的详细信息可以通过git help log
然后搜索placeholder
查看。
vim -p `git log --name-only`
git diff mybranch..master -- myfile.cs
git diff mybranch master -- myfile.cs
git merge
的标记说明git rebase --interactive HEAD~2
在打开的编辑窗口中将多次commit
的信息修改成squash
git shortlog -n -s <file_name>
git shortlog -sne
git --no-pager
直接输出到终端而不是pager
(默认为 less)查看git diff --exit-code
diff 有不同时输出 1,否则输出 0例如检查当前模块版本是否有更新:
if git --no-pager diff --exit-code package.json; then
echo 'No version update'
exit 1
fi
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.