Executing the command git clone git@github.com:whatever
creates a directory in my current folder named whatever, and drops the contents of the Git repository into that folder:
/httpdocs/whatever/public
My problem is that I need the contents of the Git repository cloned into my current directory so that they appear in the proper location for the web server:
/httpdocs/public
I know how to move the files after I've cloned the repository, but this seems to break Git, and I'd like to be able to update just by calling git pull
. How can I do this?
Go into the folder.. If the folder is empty, then:
else
Let's say you want in a folder like
/stuff
, but your pull is creating a directory under/repo/tokens/
.You can do:
That's it. You are done.
The example I think a lot of people asking this question are after is this. If you are in the directory you want the contents of the git repository dumped to, run:
The "." at the end specifies the current folder as the checkout folder.
Clone:
Clone the "specific branch":
Here's how I would do it, but I have made an alias to do it for me.
There is probably a more elegant way of doing this, however I found this to be easiest for myself.
Here's the alias I created to speed things along. I made it for zsh, but it should work just fine for bash or any other shell like fish, xyzsh, fizsh, and so on.
Edit
~/.zshrc
,/.bashrc
, etc. with your favorite editor (mine is Leafpad, so I would write$ leafpad ~/.zshrc
).My personal preference, however, is to make a zsh plugin to keep track of all my aliases. You can create a personal plugin for oh-my-zsh by running these commands:
Afterwards, add these lines to your newly created blank alises.plugin file:
(From here, replace your name with mine.)
Then, in order to get the aliases to work, they (along with zsh) have to be sourced-in (or whatever it's called). To do so, inside your custom plugin document add this:
Save your oh-my-zsh plugin, and run
allsource
. If that does not seem to work, simply runsource $ZSH/oh-my-zsh.sh; source /home/ev/.oh-my-zsh/plugins/ev-aliases/ev-aliases.plugin.zsh
. That will load the plugin source which will allow you to useallsource
from now on.I'm in the process of making a Git repository with all of my aliases. Please feel free to check them out here: Ev's dot-files. Please feel free to fork and improve upon them to suit your needs.
Basic Git Repository Cloning
You clone a repository with
For example, if you want to clone the Stanford University Drupal Open Framework Git library called open_framework, you can do so like this:
That creates a directory named open_framework (at your current local file system location), initializes a .git directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. If you go into the newly created open_framework directory, you’ll see the project files in there, ready to be worked on or used.
Cloning a Repository Into a Specific Local Folder
If you want to clone the repository into a directory named something other than open_framework, you can specify that as the next command-line option:
That command does the same thing as the previous one, but the target directory is called mynewtheme.
Git has a number of different transfer protocols you can use. The previous example uses the git:// protocol, but you may also see http(s):// or user@server:/path.git, which uses the SSH transfer protocol.