user1246462
user1246462

Reputation: 1268

Git pull only contents of a repository

Is there a way to only git pull the contents of a repository without pulling the home folder? For example I have a bunch of files in a repository called "sample" but I only want to pull the contents of "sample" into my local repository called "local." I do not want to pull "sample" such that I get: local -> sample -> [contents]. Is there a way to only pull the contents?

I'm asking because I am operating on a shared web server that requires that I place my content under a specific folder (and named certain file names within the folder).

Thanks.

EDIT: I wasn't being quite clear before. I'm working on a local machine such that I am only allowed to change the contents of my folder and not the contents of the folder that contains my folder.

Upvotes: 3

Views: 889

Answers (1)

vijay
vijay

Reputation: 2694

Option 1::

git clone <repo_path> <folder name>

So in your case, it would be git clone sample.git local

Option 2::

The folder-name where local repo is present does not have to be the same as that of the remote.

do a git clone ...

git clone repo_pathOrURL

then rename the folder

So for instance you have sample.git as your remote repository, do

git clone sample.git

This will clone the repository in a folder called sample on your local machine. Then just rename this folder to your liking, in your case local, and continue with the regular git pull and push.

Upvotes: 2

Related Questions