Way to change gitlab base url name

Hi,

My first goal is to don’t display gitlab base url name (shown when push or pull).

So i am searching a way to change my online gitlab base url name.

Actually it’s something like hxxps://gitlab.com/story and i want to use something else without the story in .git/config file.

I found some solutions that don’t satisfy me :

  • use --quiet with git command
  • use local DNS and update .git/config
  • use environment variable and tricks/update .git/config
  • ask to change my gitlab account name

Are there some other way ? Like use gitlab alias or gitlab user ID instead of name

Have a nice day guys !

You can change your username yourself in your profile and account (although as you can see there can be unintended side effects - a link explains it), see my screenshot:

although to be honest, I don’t really understand what you are trying to achieve or why you want to hide or mask it.

1 Like

yes it can be a solution but i will have to update all my git remote.

although to be honest, I don’t really understand what you are trying to achieve or why you want to hide or mask it.

it’s just the remote name from git ouput, see when you push or pull, it show the git remote name.

Well since that is related to the git command itself, it doesn’t matter if you are using gitlab, github, bitbucket since it’s the git client that is reporting the details back.

Has been asked a lot already on stackoverflow, and some people have scripted it, or just use the --quiet parameter.

it cannot even be set globally in the gitconfig, as that was what also came to my mind as an option.

Alternatively, use an IDE like Atom, VS Code and do your git actions in there for push, pull commit, and then nothing would be seen.

1 Like

Well since that is related to the git command itself, it doesn’t matter if you are using gitlab, github, bitbucket since it’s the git client that is reporting the details back.

yes you right

  • So i choose to modify gitlab username like exposed in your first message
  • From IDE, search&replace git remote name after cloning ton of repo.

With IDE you wont see the repo name etc so dont need to change anything.

If using git on command line you can use a combination of find and sed to replace the name in .git/config assuming that you clone all repos in one main directory. Then with one command you can update all files.

Here is a little example, that you can use. So I’ve simulated this:

[ian@elise test]$ pwd
/home/ian/test

[ian@elise test]$ ls
test1  test2  test3  test4

so in my test directory I have four projects. Now in each of these, I have a .git/config file, so we can now search for what we want to change, so:

[ian@elise test]$ grep -ir "gitlab.com/iwalker"
test1/.git/config:gitlab.com/iwalker/test1
test3/.git/config:gitlab.com/iwalker/test3
test2/.git/config:gitlab.com/iwalker/test2
test4/.git/config:gitlab.com/iwalker/test4

now the .git/config file has gitlab.com/iwalker and obviously I want to replace the username. Now, what we will also have to worry about is if the username is also used for login:token, so the url could be https://iwalker:mytoken@gitlab.com/iwalker/test1. So if we just tried to replace iwalker, we would replace too much of it.

So now with the find command, we want to find just .git/config. So:

[ian@elise test]$ find ./ -iname config
./test1/.git/config
./test3/.git/config
./test2/.git/config
./test4/.git/config

so in this instance, I’m not finding other files that I might not want to replace, but you may wish to filter this further by grepping the .git directory in case it find config elsewhere. Then when we want to replace the text in the files, we combine it:

[ian@elise test]$ for file in `find ./ -iname config | grep ".git"` ; do sed -i 's/gitlab.com\/iwalker/gitlab.com\/mynewname/' $file ; done

the backslash before the slash inbetween gitlab.com and iwalker is needed, because sed uses slashes as separators. Now the results:

[ian@elise test]$ grep -ir "gitlab.com/mynewname"
test1/.git/config:gitlab.com/mynewname/test1
test3/.git/config:gitlab.com/mynewname/test3
test2/.git/config:gitlab.com/mynewname/test2
test4/.git/config:gitlab.com/mynewname/test4

now you have replaced it in all your config files very quick and easily. Obviously be careful with sed, and filtering and be sure that the command does what is intended.

1 Like

yes i could do it with command line, but with IDE it’s more convenient.
I have a workspace with all my repo cloned.
i just had to search and replace “old-remote” string.
So i did it and working well.
Capture

anyway thanks for precision

1 Like

Yep, that’s another option :slight_smile:

I’m a bit of a console freak, so I do a lot of my stuff there.