Thanks @amanagar for the help . It works.I have used this command from the mentioned post. If someone face same issue like me they can use the following snippet
sudo rm -rf ~/.gitconfig
sudo rm -rf .git/config.lock
git config --global user.email "yourmail_id_registered_on_gitlab"
git config --global user.name "your_gitlab_user_name"
1 Like