Git安装与基础配置 - Angieeve/Angie-Project GitHub Wiki
1.Config的文件位置
- /etc/gitconfig 文件: 包含系统上每一个用户及他们仓库的通用配置。
git config --system
- ~/.gitconfig 或 ~/.config/git/config 文件:只针对当前用户。
git config --global
- .git/config
当前使用仓库的 Git 目录
git config --local
2.用户信息
git config --global user.name "Angie Zhang"
git config --global user.email [email protected]
3.文本编辑器 默认的文本编辑器为:
git config --global core.editor emacs
设置为notepad++
git config --global core.editor "'D:\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin '$*'"
4.检查配置信息
git config --list
查看单一配置
git config <key>
替换即可
- 获取Git仓库
git clone https://github.com/.......
note:这里最好是用SSH协议进行git仓库clone
2.基本编辑命令
- git status
- git add
- git commit
- 忽略文件
cat .gitignore - 比对三方差异
常看尚未暂存的文件更新的内容
git diff查看你已经暂存将要提交的内容git diff --cachedgit diff --staged
- git rm XXXFIle
- 移除内容
移除暂存区的内容
git rm --cached README - 移动文件
git mv fileFromA.md fileToB.md - git log
比对log差异(-p)
- git log -p -n(2,3,4,...)
查看log简略统计信息
git log --stat
git log --pretty=oneline
git log --pretty=format:"%h - %an, %ar : %s"
-
近两周内的提交
git log --since=2.weeks -
指定某人的提交
git log --pretty="%h - %s" --author=gitster -
远程仓库的使用
git remote -v
显示远程仓库使用的git
git branch -a 列出本地分支和远程分支
清理Branch
git remote prune origin
git checkout -b CSIB-L3-4 remotes/origin/CSIB-L3-4
git checkout -b L3-Jul19 remotes/origin/L3-Jul19
1.列出本地分支: git branch 2.删除本地分支: git branch -D BranchName 其中-D也可以是--delete,如: git branch --delete BranchName 3.删除本地的远程分支: git branch -r -D origin/BranchName 4.远程删除git服务器上的分支: git push origin -d BranchName 其中-d也可以是--delete,如: git push origin --delete BranchName