Is there a way to automatically set what your remotes are on a git repository after a git init?
I know I can have a git/config template, but I would need a way to reference the new repo name/directory to set the remote.
Example:
cd newProject
git init
and .git/config would already have:
[remote "origin"]
url = git@myserver:newProject
fetch = +refs/heads/*:refs/remotes/origin/*
at the end of the file.
I suppose I could do this by creating a bash script to do the git init and then append to the config file, and run that file instead of using git init, but I was hoping there was a way I could do it as part of the git init command.
You can create an alias in ~/.gitconfig. For example, to create a remote on example.com using the basename of the current directory as the project name:
If you’re project is named “foo,” when you run
git myinitin /path/to/foo it will initialize the the repository and set origin to “git@example.com:foo.git” for you.