fatal: No existing author found with 'XXX' - git-commit

I used git for the first time and I set my user name and user mail. The commands I used are below:
git config --global user.email "bob#example.com"
git config user.email "bob#example.com"
git config --global user.name "bob"
git config user.name "bob"
When I run git commit --author "bob" , I got an error fatal: No existing author found with 'bob'. How can I set user name and email?

You should stop using --author each time you commit, and instead configure an author with git config. Once you've done so, you can type git commit and the author will be pulled from your .gitconfig file.
If you want to give --author a name to use for authoring the commit, you need to use
bob <bob#example.com>
not just bob. If your author string doesn't match the user <user#example.com> format, Git assumes you've given it a search pattern, and it will try to find commits with matching authors. It will use the first found commit's user <user#example.com> as the author.

This command will do the trick:
git commit --amend -C HEAD --reset-author

Note: starting with Git 2.3.1+ (Q1/Q2 2015), the error message will be more explicit.
See commit 1044b1f by Michael J Gruber (mjg):
commit: reword --author error message
If an --author argument is specified but does not contain a '>' then git tries to find the argument within the existing authors; and gives the error message "No existing author found with '%s'" if there is no match.
This is confusing for users who try to specify a valid complete author
name.
Rename the error message to make it clearer that the failure has two
reasons in this case.
The solution remains to have the config user.name and user.email properly set, but for the case where --author is used, at least the expected argument is now clearer.
So run:
git add --all ; git commit -m "$git_msg" \
--author "First Last <first.last#company.com>"; git push

Related

Is there a Git config setting to auto-signed-off-by my commits? [duplicate]

I'm looking for a way to write the Signed-off-by: tag automatically when I commit.
I tried configuring it through the .git/config file (Reference). I put these lines of code:
[alias]
commit = commit -s
This did not work. As commented below, you can not edit git's own alias (like commit).(Reference)
I also tried using the command (Reference):
git config --global format.signoff true
Also had no effect. This explains why.
I'm looking for any solution that automatically places the tag and allows me to edit the commit message directly on git, without having to use a system alias.
[Edit made after last comment]
I think if I am guessing correctly then, you cannot alias using words which are 'reserved' words for a git command.
However if you do something like this
[alias]
ci = commit -s
Then it will do what you want it to do.
Use the commits hooks to achieve this
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks
prepare-commit-msg
The prepare-commit-msg hook is run before the commit message editor is fired up but after the default message is created.
It lets you edit the default message before the commit author sees it.
This hook takes a few parameters: the path to the file that holds the commit message so far, the type of commit, and the commit SHA-1 if this is an amended commit.
This hook generally isn’t useful for normal commits; rather, it’s good for commits where the default message is auto-generated, such as templated commit messages, merge commits, squashed commits, and amended commits.
You may use it in conjunction with a commit template to programmatically insert information.
You can use commit.gpgSign option
you can add it per repository by issuing the command below in the repo folder:
$ git config commit.gpgSign true
or for all git repository on your machine:
$ git config --global commit.gpgSign true

How can I force "git commit -s" using "git commit" command?

I'm looking for a way to write the Signed-off-by: tag automatically when I commit.
I tried configuring it through the .git/config file (Reference). I put these lines of code:
[alias]
commit = commit -s
This did not work. As commented below, you can not edit git's own alias (like commit).(Reference)
I also tried using the command (Reference):
git config --global format.signoff true
Also had no effect. This explains why.
I'm looking for any solution that automatically places the tag and allows me to edit the commit message directly on git, without having to use a system alias.
[Edit made after last comment]
I think if I am guessing correctly then, you cannot alias using words which are 'reserved' words for a git command.
However if you do something like this
[alias]
ci = commit -s
Then it will do what you want it to do.
Use the commits hooks to achieve this
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks
prepare-commit-msg
The prepare-commit-msg hook is run before the commit message editor is fired up but after the default message is created.
It lets you edit the default message before the commit author sees it.
This hook takes a few parameters: the path to the file that holds the commit message so far, the type of commit, and the commit SHA-1 if this is an amended commit.
This hook generally isn’t useful for normal commits; rather, it’s good for commits where the default message is auto-generated, such as templated commit messages, merge commits, squashed commits, and amended commits.
You may use it in conjunction with a commit template to programmatically insert information.
You can use commit.gpgSign option
you can add it per repository by issuing the command below in the repo folder:
$ git config commit.gpgSign true
or for all git repository on your machine:
$ git config --global commit.gpgSign true

Why all my Xcode commits to Bitbucket show other user 'Author Name' on Bitbucket?

When I commit and push code to bitbucket, my bitbucket show some other Author name. I used :
~ mymac$ git config --global user.name "Myfirstname lastname"
:~ mymac$ git config --global user.email "myemail#abcd.com"
:~ mymac$ git config user.name "myusername"
:~ mymac$ git config user.email "myemail#abcd.com"
:~ mymac$ cat .git/config:
Above command show right email and password. But this will only work if I commit from terminal commands. However, in my case I am committing code directly from Xcode. Any Idea?
Hey guys fortunately I found the solution to this question: Xcode use your contact card from address book as Author name to all the commits. You can change whatever username/author name you want to show on Bitbucket/Git, follow this link
https://support.apple.com/kb/PH22743?locale=en_US
to make a contact as your contact card. Check screenshots also. Select any contact and make your contact card as displayed in screenshot.
Happy Coding!!!
------------------------------------------------------------------------

Error with commiting in sourcetree for bitbucket in windows

I am a new user of bitbucket(I want to be). I have created the repository, and I have configured sourcetree. However, when I want to commit the the files, I get an error as:
git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F
C:\Users\Amir_HO\AppData\Local\Temp\uupm1wem.ugf
*** Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'Amir_HO#AmiR.(none)')
easy, just go to the source of tree options, then advanced options Take away the check mark and enter a name and email, then you give ready ok and everything worked well.

What does the git error mean "pathspec did not match any file(s)"

In a Rails app I realised I had committed a sensitive file config/credentials.yml to the git repo.
In an effort to tidy things up I followed the advice on GitHub and ran
git filter-branch --index-filter 'git rm --cached --ignore-unmatch config/credentials.yml' --prune-empty --tag-name-filter cat -- --all
and then added to gitignore
echo "config/credentials.yml" >> .gitignore
When I try to commit these changes
git add .gitignore
git commit -m "ignored credentials.yml"
I'm getting a message
error: pathspec 'adds credentials.yml to gitignore' did not match any file(s) known to git.
How can I fix this error? Or, how can I undo my changes and safely revert to the git history on my remote?
I think you might've forgotten the step
$ git add .gitignore
before trying to commit, or then you mistyped, when you shoud've given
$ git commit -m "Add credentials.yml to .gitignore"
Process advised is highly dangerous [for the repo contents], so one must be really careful to follow all the steps in detail.
Just give a file path while adding file to git add command, it works for me
$ git add mainFolder/.../file.extension
Note: mainFolder would be the folder inside your repo

Resources