Git global setup:
git config --global user.name "robertcheng"
git config --global user.email "robertcheng@xx.com"
代码下载:https 改为 ssh
git config --global url."git@coding.abc.com:".insteadOf "https://coding.abc.com/"。
执行结束后, 全局配置 .gitconfig相应改变如下
[url "git@coding.abc.com:"]
insteadOf = https://coding.abc.com/
当项目中某个文件, git add 提示如下失败时:
➜ schedule git:(master) ✗ git add aa.go
The following paths are ignored by one of your .gitignore files:
pkg/schedule
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
➜ schedule git:(master) ✗ git check-ignore -v aa.go
/Users/chengpengxing/.gitignore_global:4:schedule aa.go
➜ schedule git:(master) ✗
➜ dbs-apiserver git:(tpaas_recover) ✗ git rev-parse --abbrev-ref HEAD
tpaas_recover
➜ dbs-apiserver git:(tpaas_recover) ✗
➜ dbs-apiserver git:(tpaas_recover) ✗ git log --date=iso --pretty=format:"%cd @%h" -1 // 返回最后一次提交的时间和commit id
…或在命令行上创建一个新的存储库
git clone https://coding.jd.com/stardb/aaa.git
cd aaa
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
…或从命令行推送现有空的存储库
cd existing_folder
git init
git remote add origin https://coding.jd.com/stardb/aaa.git
git add .
git commit -m "Initial commit"
git push -u origin master
…或从命令行推送已有存储库
cd existing_repo
git remote set-url origin https://coding.jd.com/stardb/aaa.git
git push --all https://coding.jd.com/stardb/aaa.git