- git branch -a: 可以查看本地分支和远程分支情况
- git checkout -b fix-failing-tests origin/fix-failing-tests: 从远程分支拉取更改
- 创建了一个名为 fix-failing-tests 的新分支
- checkout 那个分支
- 将更改从 origin/fix-failing-tests 拉到该分支
- git remote show origin: 查看本地分支和追踪情况
- git remote add origin [url]: 新增远程仓库
- git remote prune origin: 同步远程分支情况到本地,如果远程删除了分支,本地就会同步过来。
- git branch -D [branch name]: 删除本地分支
- git push origin --delete Chapater6:可以删除远程分支Chapater6
- git fetch -p: 远程分支被删除了,同步到本地
- git checkout commitId -b [branch name]:从某个commit点切出一个新分支
- git config --global credential.helper store: 记住git的http用户名密码
- git rm -r --cached [file]: 从git仓库移除文件,不会删除该文件
- git commit --amend:git 修改最近一次commit 的注释
- 配置mergetool和difftool
git config --global merge.tool bc3
git config --global mergetool.bc3.path "E:\Program Files\Beyond Compare 4\BCompare.exe"
git config --global diff.tool bc3
git config --global difftool.bc3.path "/usr/bin/bcompare"
- git status显示中文乱码
git config --global core.quotepath false
- git log显示中文乱码
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding utf-8
echo "LESSCHARSET=utf-8" >> ~/.bashrc && source ~/.bashrc
- git记住http用户名密码
git config --global credential.helper store
- git新增tag
git tag -a <版本号> -m "<备注信息>"
git push origin --tags
- git删除tag
git tag -d V0.2.0
git push origin :refs/tags/V0.2.0
- git查看tag
git show V0.2.0 (可以看到对应commit id)
git tag -l -n
- 将远程指定分支 拉取到 本地指定分支上:
git pull origin <远程分支名>:<本地分支名>
- 将远程指定分支 拉取到 本地当前分支上:
git pull origin <远程分支名>
- 查看stash保存的时间
git stash list --date=relative
git stash list --date=short
git stash list --date=loca
git 使用ssh密钥
1、生成公钥:ssh-keygen -t rsa -C “your_email@youremail.com”
2、查看公钥:cat ~/.ssh/id_rsa.pub // windows in user dir
3、登陆你的github帐户。点击你的头像,然后 Settings -> 左栏点击 SSH and GPG keys -> 点击 New SSH key