![]() ![]() (I am not very good with git, so for now I am just trying to follow the explanations given in internet. If I type git show commit_id I still see the commit with the old message.ĭoes anybody has an idea how to remove this commit message completely from git? I tried the whole procedure described here (Amending the message of older or multiple commit messages) but I am still being displayed the commit messages appear "under" the tag 1.0 (I am using SmartGit, that's why I am saying "under"). In my case the code where the commit messages appears is under the tag 1.0. For example in branch v1.0, I have a fix (which represents a new version) tagged as 1.1. At each new release of my code I also put a tag on each branch to start and later to follow the different fixes (1.0, 1.1, and so on). The commit I want to update its messages was made at the time when the branch v1.0 was the 'master'. The new changes will be added to the amended commit. This will have Git open the configured system editor and let you modify the last commit message. Once you have made more changes in the working directory and staged them for commit by using git add, you can execute git commit -amend. In my case I have, of course, my master branch and several other branches, for example v1.0, v2.0 and v3.0. In this case you can amend the most recent commit. Pygit2.Repository(".").I am in a situation where I would like to edit the commit message of an old, already pushed code. In the post-checkout script it’s possible to extract the the git commit message template file path from the git configuration.Git config -global core.hooksPath /path/to/my/centralized/hooksĪnd installing the commit template globally: git config -global commit.template. It’s possible to use the same configuration across all repositories, by using a global git hooks path (as seen here):.Using the filename from the example above, we get: git config commit.template. With open(GIT_COMMIT_TEMPLATE, "w") as file: GIT_COMMIT_TEMPLATE = ".git/.commit-template"īranch_name = pygit2.Repository('.').head.shorthand For example, if your feature branches names are ISSUE-123/feature/new-awesome-feature, and you want the commit message to be prefixed with the issue key ISSUE-123, then the following script could be used (I prefer Python): #!/usr/bin/env python3 If, like me, your goal is to preload a commit message based on the branch name, you can use a workaround in which a static commit message template is generated dynamically every time the post-checkout git hook is triggered.įirst, install a git post-checkout hook that writes a commit message template based on the branch name. See also here If you want to remove it from a remote repo follow the same steps and push afterwards. Then commit (or commit -amend) to remove the file from the last commit (it stays in in the history, though). However, since SmartGit 18.2, commit message templates are supported ( SmartGit What's new). git rm file or git rm -r directory (if you add the -cached -flag the file doesnt get removed from your filesystem). Unfortunately, SmartGit does not support pre-commit git hook. ![]() Where tmplfile is the file which contains your commit message template including the path there from your git project's root. To set this in Smartgit, go to "Tools">"Open git shell", then type To use a template you must set the commit.template option in git-config. ![]() If your preloaded commit message doesn't have anything dynamic or which would require a shell script to work out, a template may be the more appropriate route. Git hooks are more versatile than templates. git/hooks directory should give you a good start on writing your own. ( see My post and the two older posts to which it refers )Ĭommit-msg will also allow you to modify the commit message, but does so after the user has sent the messages. Unfortunately Smartgit does not support this hook. Prepare-commit-msg is probably the better suited to your purposes as it allows you to pre-fill the commit message before the user sees it. There are 2 hooks which may be of interest to you: ![]()
0 Comments
Leave a Reply. |