0

I'm using git on my desktop computer with user name defined in --global. Now I would like to checkout project as other user. But when I did commit I found that it is done by my main user.

I did init and set local user:

git init
git config --local user.name "user2"
git config --local user.email "[email protected]"

I did clone

$ git clone https://[email protected]/xxx/tst.git

Did changes, commit and push:

git add *
git commit -m "aaa"
git push

In bitbucket webpage I found that commit was done by main user. How to make commit as local user?

1
  • 1
    Why did you clone after the init? What about rerunning the config commands in the cloned repo? Commented Apr 26, 2022 at 9:38

1 Answer 1

1

The names of these flags can be confusing, especially when you compare them to those used by package managers such as pip and npm.

git config --local affects the current repository, not the current (local) user. So you should run it inside the repository that you just cloned:

$ git clone https://[email protected]/xxx/tst.git
$ cd tst
$ git config --local user.name "user2"
$ git config --local user.email "[email protected]"

git config --global, on the other hand, affects the current user.

git config --system would affect all users on the system. This is rarely what you want; I've never used it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.