git经常使用命令

git log 显示日志

git reset --hard 1094a 回退到指定版本

git remote add tomcat https://github.com/apache/tomcat.git 添加远程仓库

git pull tomcat 从指定远程仓库更新

git branch -a  查看全部分支
git branch dev //建立分支
git checkout dev //切换分支

git push origin dev //将本地分支上传到远程分支 dev表示本地分支

git branch --set-upstream branch-name origin/branch-name// 建立本地分支与远程分支对应关系

git branch --set-upstream-to=origin/master //关联分支git

 

git checkout -b 本地分支名 origin/远程分支名 //将远程git仓库里的指定分支拉取到本地(本地不存在的分支)

从本地推送分支,使用git push origin branch-name,若是推送失败,先用git pull抓取远程的新提交;

在本地建立和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致;

创建本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name;
git push origin [本地分支名]:[远程分支名]
git checkout -- readme.txt //用暂存区覆盖工做区
git reset HEAD -- . //撤销全部 本地仓库覆盖暂存区 
git reset HEAD -- filename 撤销特定目标 
git pull origin <远程分支名>:<本地分支名> //将远程指定分支 拉取到 本地指定分支上:
git pull origin <远程分支名> //将远程指定分支 拉取到 本地当前分支上:
git pull origin //将与本地当前分支同名的远程分支 拉取到 本地当前分支上(需先关联远程分支)
git push origin <本地分支名>:<远程分支名> //将本地当前分支 推送到 远程指定分支上(注意:pull是远程在前本地在后,push相反):

git push origin <本地分支名>//将本地当前分支 推送到 与本地当前分支同名的远程分支上(注意:pull是远程在前本地在后,push相反):

git push origin //将本地当前分支 推送到 与本地当前分支同名的远程分支上(需先关联远程分支)

#提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true

#提交时转换为LF,检出时不转换
git config --global core.autocrlf input

#提交检出均不转换
git config --global core.autocrlf false

2.二、safecrlf

#拒绝提交包含混合换行符的文件
git config --global core.safecrlf true

#容许提交包含混合换行符的文件
git config --global core.safecrlf false

#提交包含混合换行符的文件时给出警告
git config --global core.safecrlf warn
相关文章
相关标签/搜索