6

If I have a gitlab account, username: account1 email: email1@outlook.con

the initial setting in terminal:

git config --global user.name account1
git config --global user.email email1@outlook.con

if I have another one gitlab account, username: account2 email: email2@outlook.con

when I change the user info in termal:

git config --global user.name account2
git config --global user.email email2@outlook.con

I push file to gitlab , the "Activity" info still show account1.


and I push file by tortoisegit through https path.

I found that even deleted the SSH KEY in gitlab, can still be to push file by https path.


I need to reset? How can I do?

*I removed the git and re-installed, and found that the user information still exists...

Finn
  • 1,323
  • 5
  • 24
  • 46

2 Answers2

4

Author/committer info (name+email) is written in every commit. The info is copied to commits from config so you have to edit config before making commits.

If you have made a mistake and want to change author/committer name — see https://stackoverflow.com/a/750182/7976758.

If you have two different identities I recommend to put them into different git config files — one global and one local for a project:

git config --global user.name account1
git config --global user.email email1@outlook.con
git config user.name account2
git config user.email email2@outlook.con
phd
  • 82,685
  • 13
  • 120
  • 165
  • I want to remove the old user to switch to the new user. But such a change may be lost terminal settings with gitlab... – Finn Jun 08 '17 at 02:31
0

I am using this script for switching git accout configuration

#!/bin/sh

if [[ -f ~/.ssh/home ]]; then
    echo "swith to home"
    mv ~/.ssh/id_rsa ~/.ssh/work; mv ~/.ssh/home ~/.ssh/id_rsa
    git config --global user.email "user.name@email.com"
else
    echo "swith to work"
    mv ~/.ssh/id_rsa ~/.ssh/home; mv ~/.ssh/work ~/.ssh/id_rsa
    git config --global user.email "user2@email.eu"
fi

ssh-add -D
ssh-add