Domanda

My problem is, I've added a remote of live to a current repo.

$ git remote add live ssh://user@myserver:port/directory

I've then pushed this repo to bitbucket and then cloned on another machine, however when clone the repo it doesn't have the remote settings that I put in the initial repository.

I have to add it every time, is there a way to add it so that it works across the board - or works within each repo that I add it to? Or am I doing something wrong when I add the live remote?

Thanks

È stato utile?

Soluzione

No you are not doing anything wrong.

The ideal way to run a sequence of steps after a particular type of action would be to use a git-hook for that action. However, that won't be possible here - there is no git-clone hook in git which could do that for you -- i.e.,automatically add a remote whenever a new clone is made for you.

Check out answers on git-clone and post-checkout hook and is there a clone hook.

Basically, If you were cloning the same repo on the same machine again and again, then you could have used --template flag for the hook; However, since you are checking out the repo on different machines everytime, you will need to copy the template hook on each new machine, which is bad.

It is better that you run the command git remote add live ssh://user@myserver:port/directory everytime you clone the repository, from within the cloned repository.

You can then run git remote -v to check all the remotes available in the repository.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top