Git全局设置
git config --global credential.helper cache #or store
git config --global credential.helper 'cache --timeout=3600'
git config --global credential.helper store
git config --global user.name "name"
git config --global user.email "*****@163.com"
创建Git仓库
mkdir mytest
cd mytest
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/******/mytest.git
git push -u origin "master"
已有仓库
cd existing_git_repo
git remote add origin https://gitee.com/******/mytest.git
git push -u origin "master"
下拉代码
git pull -- rebase [remote ] [remote--branch] //远程分支与本地分支强行合并
git fetch [remote] [ [remote--branch] //拉取远程你要合并的分支到本地
上传代码
强制推送到远程分支master
git push -f origin master
从本地提交到远程分支,-u添加默认上游
git push -u origin master
取消操作
查看commit id
git reflog
回退到指定id
git reset --hard a7e1d279
(使用 "git reset HEAD <文件>..." 以取消暂存)
(使用 "git checkout -- <文件>..." 丢弃工作区的改动)
清除缓存
git credential-cache exit #这个命令会立即终止凭据缓存,并清除缓存中的所有凭据
git credential-cache erase #这个命令会清除缓存中的特定凭据,然后你可以再次输入用户名和密码来重新验证