-
Notifications
You must be signed in to change notification settings - Fork 54
git常用问题 #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
如何补交自己的 github commit利用 git commit --date 的操作,可以指定 commit 的时间。这个是属于补交的操作。如果有修改 commit 时间的操作,就需要用到 git commit --ament,进入交互模式修改。 首先,获取到你想补交的时间。mac 下的获取时间的命令是
得到时间后,就可以补交 commit 啦。 |
Commit message 规范
|
|
Uh oh!
There was an error while loading. Please reload this page.
git的公钥
前者可以随意克隆github上的项目,而不管是谁的;而后者则是你必须是你要克隆的项目的拥有者或管理员,且需要先添加 SSH key ,否则无法克隆。
https url 在push的时候是需要验证用户名和密码的;而 SSH 在push的时候,是不需要输入用户名的,如果配置SSH key的时候设置了密码,则需要输入密码的,否则直接是不需要输入密码的。
进入该文件夹下检查有没有id_rsa.pub 或 id_dsa.pub 文件,如果存在 则已经创建,没有需要创建
代码参数含义:
执行后,会填写保存两种密钥的文件夹,和passphrase,全部可以按enter。然后执行ls来查看生成后的文件。
在config里面添加
或者直接copy
2.登录github ,个人中心 ,ssh key ,添加 Add SSH key
就是把https的链接方式
修改远程仓库地址
有时候push不上去,提示 the project you were looking for could not be found. 可能是远程仓库地址换了。
删除的文件恢复
批量
git ls-fies -d | xargs git checkout --
git 默认不区分文件名大小写
git config core.ignorecase false
多个github账号的问题
查看某个commit 具体的代码更改
git diff
分支问题
从远程 master 切出分支,不要将本地分支 feature 功能带上
查看log
查看某个文件历史修改记录
git log src/index.js
一行展示
--oneline
作者
--author="sunyongjian"
过滤合并
--no-merges / merges
根据提交信息
--grep=""
查看跟关联的分支和tag,比如从这个commit提交到origin/develop
--decorate
结合展示分支结构,merge的去向
--graph
按作者分,所有的commit
git shortlog
diff改动
--stat
哪些文件有改动,改动的行-p
具体的代码按数量
-10
自定义格式
%cn、%h 和 %cd 这三种占位符会被分别替换为作者名字、缩略标识和提交日期。
git log --pretty=format:"%cn committed %h on %cd"
查看某个commit的改动
git show hash
查看历史操作
git reflog
可以撤销一些不可逆的操作。比如reset之后,找到reset之前的commit hash,再reset
git show HEAD === git log -1 -p
The text was updated successfully, but these errors were encountered: