git-commit

git log show one commit id only

三世轮回 提交于 2019-11-30 04:10:41
I need some help. It is possible to only show one commit id? Since git log -3 show the log from 1 - 3, I just want to show only 3. What possible command will match for it? I use the command git log -3 --pretty=format:"%h" the result is ffbef87 cf0e073 1c76c5d I only want to display the 1c76c5d only. Enrico Campidoglio You can use git show referencing the third parent from your current commit (i.e. the second ancestor from HEAD ). Also, git show accepts the same format string as git log : git show HEAD~2 --pretty=format:"%h" --no-patch Update ( 2016-12-01 ) An even better way would be to use

Exit Vim without committing changes in Git

旧巷老猫 提交于 2019-11-30 02:42:20
When I use git commit --amend or git rebase -i , vim opens up for me to make changes. If I then change my mind and exit vim without making any changes, a commit is still made which shows up in git reflog . How do I exit the editor without committing anything? To get git to not make a change when you are executing git commit --amend or git rebase -i . Just delete the message (and save). All git does is look for a non empty message to see if a valid commit happened. Since there is a commit message (because you commited something before) git thinks that its a valid commit or rebase. EDY

How to list all my TODO messages in the current git managed code base

南楼画角 提交于 2019-11-29 21:49:42
I want to see all TODO comments that only I wrote and that exist in the current code base that is git managed. What I've got so far is printing all TODO comments that I've ever created or modified during the complete git history: git log -p --author="My name" -S TODO | grep "\+.*TODO" But this tool chain lists all TODO comments ever written, even those that I've already resolved and thus removed again from code. Is there a tool that can search the current code base line-by-line, check if it contains "TODO" and if this line was authored by me and then print those lines? You can combine git

Git prevents pushing after amending a commit

依然范特西╮ 提交于 2019-11-29 21:18:54
Usually, I just run git add file git commit git push but if I amend the commit before pushing it (with git commit --amend ), the next push fails with hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. How can I let git push the changes without merging branches? I only have one branch ( master ) and I'm the only person using this repo so why is it saying this? git branch -a: * master

Couldn't set refs/heads/master when commit

╄→尐↘猪︶ㄣ 提交于 2019-11-29 20:02:18
问题 I was able to commit fine yesterday. But today (I didn't change anything), when I commit: $ git add config.h $ git commit -m "Update config.h to reset the values" error: Couldn't set refs/heads/master fatal: cannot update HEAD ref I know that this error may happen also during pull or push. But I haven't found a solution to fix it when committing. My .git/config file looks like this: [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false

Git commit opens blank text file, for what?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 18:54:47
In all the Git tutorials I've read they say that you can do: git init git add . git commit When I do that I get a big text file opened up. None of the tutorials seem to address this, so I don't know what to do with the file or what to put in it if anything. vikhyat You're meant to put the commit message in this text file, then save and quit. You can change the default text editor that git uses with this command: git config --global core.editor "nano" You have to change nano to whatever command would normally open your text editor. Will Robertson As mentioned by Ben Collins , without the -m "..

Standard to follow when writing git commit messages [duplicate]

廉价感情. 提交于 2019-11-29 18:45:45
This question already has an answer here: Git Commit Messages : 50/72 Formatting 5 answers I find myself managing very many files (over 60 but below 70) and my commit messages so far follow this pattern: when I have added something like on layout.css , my commit message is "added something on layout.css file" , and when I remove something, my commit message is "removed something from layout.css file" . Some files down the line, I look at my commits feed and added... and removed... messages dominate. Sometimes I don't remember what I removed or what I added in layout.css since I make so many

Edit an incorrect commit message in Git that has already been pushed

北城以北 提交于 2019-11-29 07:41:34
问题 I did a Git commit and push, but wrote the totally wrong thing in the comment. How do I change the comment? I have already pushed the commit to the remote. 回答1: git commit --amend will allow you to edit the commit message. If you already pushed that commit, you need to run git push --force . Only do that if you are sure nobody pulled it yet! If people pulled the commit from your repo, simply leave the message as it is. 回答2: If you wrote the wrong thing and the commit has not yet been pushed,

How to sign-off (“signed-off-by”) a Git commit in PyCharm?

南楼画角 提交于 2019-11-29 07:08:45
问题 I wonder how I can add the "signed-off-by" line in a Git commit automatically within PyCharm's Commit dialog. There are options for amending to the previous commit and changing the author of the commit, but I couldn't find an option for adding the signed-off line ( git commit -s ) on a per-commit basis. Is it even possible or is it a missing feature? 回答1: For anyone getting this answer in google searches, here is the solution as tested in Ubuntu 16.04: echo 'no-tty' >> ~/.gnupg/gpg.conf echo

Telling if a Git commit is a Merge/Revert commit

南笙酒味 提交于 2019-11-29 02:50:45
I am writing a script that requires checking whether a particular commit is a Merge/Revert commit or not, and I am wondering if there is a git trick for that. What I came up with so far (and I definitely don't want to depend on the commit message here) is to check HASH^2 and see if I don't get an error, is there a better way? Figuring out if something is a merge is easy. That's all commits with more than one parent. To check for that, you can do, for example $ git cat-file -p $commit_id If there's more than one `parent' line in the output, you found a merge. For reverts it's not as easy.