0

It may seems too hacky and maybe require some kind of git plugin.

What i'm trying to do is to clone a github page to :githubsername/:repoName

for example git clone 'git@github.com:bekicot/assignment_rss.git

would result to clone the repo to assignment_rss directory. I want it to automatically clone it to bekicot/assignment_rss.

This is what i currently do git clone 'git@github.com:bekicot/assignment_rss.git bekicot/assignment_rss

As you can see, it require more character.

Are there any simplified way or maybe git settings that hook to the git clone and overrides the cloning default settings ?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Yana Agun Siswanto
  • 1,932
  • 18
  • 30

2 Answers2

1

Git cannot guess what you want.

You will have to write script that does it for you.

Git settings are values which control the way git will behave (white spaces, colors, diff toll etc) but there isn't anything which can guess what is your desired name for the cloned folder.

Script is very simply to write and it will only require few lines of code.


Sample code

#!/bin/bash
githubsername='aaa'
repoName='bbb'

git clone 'git@github.com:$githubsername/$repoName.git $githubsername/$repoName
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
0

1 year later. I did managed to create a bash function a long time ago that do exactly what i want (only work with https/http protocol. I forgot to put here, just in case somebody need it ;)

github_clone () {
    DIRECTORY=$1
    DIRECTORY=${DIRECTORY#*com/}
    DIRECTORY=${DIRECTORY: : -4}
    git clone $1 $DIRECTORY
}

example

$ github_clone http://github.com/rbenv/rbenv
Yana Agun Siswanto
  • 1,932
  • 18
  • 30