配置 ssh
ssh-keygen -t rsa -C "your_email@example.com"
Git init
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://xxxxx/git_test.git
git push -u origin "master"
Git 配置用户信息
git config user.name "xxx"
git config user.email "xxx@xx.com"
Pull
git pull --rebase origin master
Push
git add README.md
git commit -m "上传laravel-admin"
git push origin master
查看当前分支
git branch
切换到其他分支
git checkout -b develop origin/develop
切换回master分支
git checkout master
合并分支
git checkout master
git pull
git checkout dev
git merge master
git push origin dev
git merge dev
解决多人开发冲突
1.git stash
2.git pull
3.git stash pop
git add xxx
用远程仓库中的代码覆盖本地仓库代码
git reset --hard
git pull
.gitignore 失效解决办法
git rm -r --cached .
git add .
git commit -m "update .gitignore"
给仓库代码打标签
git tag
git tag v1.0
git tag -d v1.0
git show v1.0
git push origin v1.0
git push origin --tags
git push origin --delete v1.0
统计每个人代码增删行数
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
查看仓库提交者排名前5
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5
仓库总提交统计
git log --oneline | wc -l