Skip to content
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

git操作 #23

Open
liucaieson opened this issue Jun 14, 2021 · 0 comments
Open

git操作 #23

liucaieson opened this issue Jun 14, 2021 · 0 comments

Comments

@liucaieson
Copy link
Owner

liucaieson commented Jun 14, 2021

git rev-parse HEAD
获取当前最后一个的 commit hash

HEAD可以换成分支,获取该分支最后一次提交

git rev-parse --abbrev-ref HEAD
获取当前分支名

上面命令都说是获取当前的XX,
也就是说你运行命令时所在的 git 目录,
如果我想要在任何的地方运行这个命令呢?这时候就需要你明确指出.git目录的位置以及git对应的工作目录

git --git-dir='./maleskine/.git' rev-parse --abbrev-ref HEAD

可以看到上面命令行中,我并没有直接在maleskine目录下运行,通过设置--git-dir选项,也可以正确的获取到maleskine项目当前的分支名。git还有一个选项--work-tree可以指定git的工作目录

git commit -a --amend
修改本地的最后一次提交信息
-a是add的简写 这样是add 和commit的操作一起执行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant