- 用户名和email
- -global 参数会将这些记录在 ~/.gitconfig 文件,作为默认值
$ git config --global user.name "Scott Chacon" $ git config --global user.email "[email protected]"
- -global 参数会将这些记录在 ~/.gitconfig 文件,作为默认值
- 配置默认文本编辑器
$ git config --global core.editor 'emacs'
- 查看设置值
$ git config user.name
- 自己编辑文件内容
/etc/gitconfig # 全部用户有效 ~/.gitconfig # 当前用户有效 .git/config # 当前项目有效
- 本地初始化
#项目根目录 git init
- 克隆远程库代码
git clone resp_url
- 添加到本地库
git add fileName git commit -m 'commit content'
- 提交到远程库
#origin:远程库名 master:分支名 git push origin master
- 添加上游仓库
git remote add upstream resp_url
- 从上游仓库获取到分支,及相关的提交信息,它们将被保存在本地的 upstream/master 分支
git fetch upstream
- 切换到本地分支
git checkout master
- 把 upstream/master 分支合并到本地的 master 分支
git merge upstream/master
- 从远程origin仓库的master分支下载到本地并新建一个分支temp
git pull origin master:temp
- 比较两个分支的不同
git diff temp
- 删除快照和硬盘中的文件
git rm fileName
- 更改提交到本地
//-m 提交注释 //-a 自动将在提交前已记录、修改的文件放入缓存区 git commit -a -m 'remark info'
- 提交到远程库
git push origin master
- clone is for fetching repositories you don’t have
- checkout is for switching between branches in a repository you already have
- the answer is coming from: http://stackoverflow.com/questions/7298598/what-is-the-difference-between-git-clone-and-checkout
https://my.oschina.net/u/1186749/blog/668488
git rm -r -n --cached "bin/" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。 git rm -r --cached "bin/" //最终执行命令. git commit -m" remove bin folder all file out of control" //提交 git push origin master //提交到远程服务器
- 查看文件提交记录
git log --pretty=oneline filename
- 查看某次提交变动详情
git show commitHash