Git工作笔记

来源:互联网 发布:2k17樱木花道脸部数据 编辑:程序博客网 时间:2024/04/27 01:12
Git文档:  http://git-scm.com/book/zh/v1


git diff file 工作区与暂存区对比
git diff --staged file 暂存区与服务器对比
git diff HEAD file 工作区与服务器对比


git rm file 删除文件,
git rm -f file 删除已加入暂存区的文件需要加-f


git log -p -2 显示最近2次修改内容
git log --pretty=short 显示简短一点的log信息


git commit --amend 可以修改已提交的信息,保持change-id不变,认为是同一次提交
git commit -a -m 'logmsg' 不通过staged状态直接提交


git branch name 创建分支
git merge branch_name 合并分支


git reset file 恢复暂存区中的修改,不改变工作区内容,同git reset HEAD file,同git rm --cached file
git reset --hard 恢复暂存区、工作区所有修改


git checkout -b name 切换分支,不存在则创建
git checkout file 恢复本地未add 修改,用暂存区文件取代工作区文件


冲突时临时保存本地修改
git stash ->git pull/git merge ->git stash pop


重命名文件
git mv filefrom fileto


查看git帮助
git help commit/add


git remote -v 查看远程分支信息
git config --list 查看配置信息


更新命令
git fetch origin
git pull origin

推送命令
git push origin HEAD:refs/for/branch_name


git 命令添加别名
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status


windowns下使用Git bash ls命令中文文件名乱码:
编辑C:\Program Files\Git\etc\git-completion.bash最下方加入
alias ls='ls --show-control-chars --color=auto'


windows下使用TortoiseGit查看linux服务器上的代码状态时,文件内容一样但是显示已修改:
忽略权限检查,只显示真正修改的文件
git config --global core.filemode false
git config core.filemode false



修改git commit 除了 git commit --amend 还有 git commmit rebase, reset:
http://blog.csdn.net/tangkegagalikaiwu/article/details/8542827
0 0
原创粉丝点击