I have a Gitlab repo which has a main branch that is very large. I only want to use one folder in the repo, so I created a branch and removed all content other than the folder I wanted to use. Then, I cloned the branch with a deploy token (with full permissions) and the branch flag to specify the branch:
git clone --branch my_branch https://oauth2:[MY_TOKEN]@gitlab.com/my-repo.git ./save_location
This is fine, I have no problem at all cloning the repo. And if I want to get any updates to the folder that were pushed to the master branch, I can pull the master into my branch, with the -X theirs
flag set. I checked the git documentation, and when cloning with the branch flag set, the repo still tracks all other branches so this pull still works as expected. So here is the command:
git pull origin master -s recursive -X theirs
This seems to be straightforward enough, but attempting the pull will present this error:
* branch master -> FETCH_HEAD
Committer identity unknown
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
If I am using a deploy token to access the repo, and the token has full permissions, then why am I still being asked to provide an identity? How can I resolve this issue without configuring an identity? I want to assure that this is a completely faceless system with no dependencies on an account.
CodePudding user response:
The prompt you're getting is because you're making a merge commit, and Git needs a committer identity to put into the commit. user.name
is a personal name, not a username, and user.email
is the email. These are unrelated to your account on GitLab, have nothing to do with authentication, and are set purely locally, but in order to create a commit you must set them (or specify them using a different method, like environment variables).
You can work without setting author or committer identities provided you create no commits, but if you create commits, you have to specify something. You can specify a machine account if you like with an invalid email address (e.g., [email protected]). If this is a script and you don't want to rely on changing the local config, you can use the environment variables GIT_AUTHOR_NAME
and GIT_AUTHOR_EMAIL
and their committer counterparts to specify the values from the environment. The git commit
manual page explains these variables and their use.