Git 笔记
来源:互联网 发布:linux配置gradle 编辑:程序博客网 时间:2024/05/22 07:56
1. Checkout Remote Branches:
$ git checkout -t origin/haml
参考:checkout tracked remote branch
2. List Remote Branches:
git branch -r # remote branches
git branch -a# all branches
git branch # local branches
List Remote Branches
3. 恢复删除的或者修改的文件
git checkout-- file-name # 加'--',表示后面的是文件名,而不会把它当作命令的其他类型的参数,比如tag名
git reset commit-id 恢复到某次commit,如HEAD
git reset--soft commit-id 恢复到某次commit,保留至此commit之后的修改在staging
4. 删除本地/远程 branch
To delete a local branch
To remove a remote branch (if you know what you are doing!)
参考:https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote5.checkout -b
创建并切换到新分支,当前分支为之前的工作区的内容。
6. git stash
保存当前工作区,包括stage(git add后,但没有commit的)。
stash不属于某个branch,可以checkout任意branch,然后apply。
git stash : 保存当前修改
git stash list : 查看当前有那些stash
git stash pop: 使用stash栈头
git stash apply stash@{0} : 使用某个stash
7. git push local branch to origin
git push -u origin branch_name
8. git push --force remote_name remote_branch
rewrite the remote branch
9. remote
git remote add origin git@github.com:caius/foo.git
git remote -v
10. 查看某个文件的修改历史
git log --pretty=onelinefile-name
11. 查看某个cmmit修改的文件
git show --pretty="format:" --name-only file-name
http://stackoverflow.com/questions/424071/list-all-the-files-for-a-commit-in-git
FAQ:
1. Can I destroy and recreate a Git remote branch in one command?
- Git -> git log笔记
- Git 笔记 git add
- Git 笔记, git commit
- 【git】git学习笔记
- git笔记
- git笔记
- git笔记
- git笔记
- git笔记
- git 笔记
- git笔记
- git 笔记
- git笔记
- Git 笔记
- GIT笔记
- Git笔记
- Git笔记
- [笔记]Git
- not-null property references a null or transient value:
- adb 传送 intent boolean extra value
- VS2008如何将变量和控件相关联
- TCP/IP - 2.4 分配并初始化sock结构
- 转,yum第三方源
- Git 笔记
- Java谜题畅读版之更多的类谜题
- TCP/IP - 2.5 TCP协议对sock结构初始化
- Web 服务器被配置为不列出此目录的内容。??
- window.location.href/replace/reload()--页面跳转+替换+刷新
- 使用 dom4j 解析 XML
- 游戏中的凄美台词
- data
- TCP/IP - 2.6 socket与文件系统的关联