git笔记

  • 关系图

  • 相关命令

git clone
git remote update
git reset [file] //重置暂存区的指定文件,与上一次commit保持一致,但工作区不变
git reset --hard FETCH_HEAD //重置暂存区与工作区,与上一次commit保持一致
git add ./[file1] [file2]
git commit [file1] [file2] -m 'message'
git status
git log
git diff
git diff [first-branch]...[second-branch]
git pull [remote] [branch] //取回远程仓库的变化,并与本地分支合并
git push [remote] [branch] //上传本地指定分支到远程仓库
git push [remote] --force //强行推送当前分支到远程仓库,即使有冲突
git push [remote] --all //推送所有分支到远程仓库

git branch --set-upstream-to origin/dev 本地分支与远程分支建立映射

git branch //所有本地分支
git branch -r //所有远程分支
git branch -a //所有本地分支和远程分支
git checkout -b [branch] //新建分支并切换
git branch --track [branch] [remote-branch] // 新建分支,与指定远程分支建立追踪关系
git checkout [branch-name] //切换到指定分支,并更新工作区
git checkout - //切换到上一个分支
git merge [branch] //合并指定分支到当前分支
git branch -d [branch-name] //删除分支
git push origin --delete [branch-name] //删除远程分支 git branch -dr [remote/branch]

git checkout -- _mod/mod_admin.php //取消本地修改

git clone http://username:password@gits.xxx.git  //强制用户名密码拉取

git config --system --list

git config --global  --list

git config --local  --list

git config --global user.name "myname"

git config --global user.email  "test@gmail.com"

 

git config --global core.quotepath false  //解决git显示乱码

 

放弃本地修改,强制拉去最新

git fetch --all
git reset --hard origin/master
git pull 

git ignore 添加忽略文件不生效解决办法

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

一直提示输入git用户名及密码:Username for 'http://gits.huicui.me

git config --global credential.helper store

git 撤销,放弃本地修改

参考地址:https://www.cnblogs.com/qufanblog/p/7606105.html

原文地址:https://www.cnblogs.com/wanghaokun/p/9891446.html