How to clone/connect a remote GIT repository without initial loading files and history?

I want to prepare a development VM for our project that contains all required stuff for the developers (such as IDEs, Browsers, Tools, Bookmarks, GIT repositories, etc)

As this is an already long ongoing project, the size of the repositories grew up to > 3 GB and as we're serving micro services, not every developer needs to have all of them.

To keep the initial VM file size small, I want to know how I could "prepare" the VM with configured git repositories (so that the developers could easily get their code by "git fetch && git checkout xy") without downloding all the code in advance.

You can just create all the repo folders and setup the remote. Here's an example:

C:\Users\yogesh\Desktop>md test123
C:\Users\yogesh\Desktop>cd test123
C:\Users\yogesh\Desktop\test123>git init
Initialized empty Git repository in C:/Users/yogesh/Desktop/test123/.git/
C:\Users\yogesh\Desktop\test123>git remote add origin https://github.com/org1/repo1.git

Do this for all the repos. This should just create an empty directory with a git repo configured to point to actual remote repos. Once a dev needs to setup the repo they can just do:

git fetch
git checkout <branch>

How can I checkout or download single file from GitHub repo, How do I find a file from a git repository? To see which remote servers you have configured, you can run the git remote command. It lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see origin — that is the default name Git gives to the server you cloned from:

  1. Make a mirror clone of the repository under $MIRROR. $MIRROR could be /opt/ for example. git clone <remote_repo> --mirror -- /opt/mirror_repo. $MIRROR could also be located in a mounted device.

  2. Every user makes a clone by using /opt/mirror_repo as a reference. cd /home/userA/;git clone <remote_repo> --reference=/opt/mirror_repo, cd /home/userB/;git clone <remote_repo> --reference=/opt/mirror_repo.

  3. Train the developers to use git worktree to checkout different revisions to different working trees instead of making new clones. If they insist on new clones, tell them to always add --reference=/opt/mirror_repo.

  4. Run a scheduled task to update /opt/mirror_repo regularly, at 00:00 everyday for example. git --git-dir=/opt/mirror_repo fetch.

A reference repo can reduce network and local storage costs.

Tutorial: Open a project from a repo, and then manually transfer it to your target server. At this point, you have a Git repository with tracked files and an initial commit. Cloning an Existing Repository If you want to get a copy of an existing Git repository — for example, a project you’d like to contribute to — the command you need is git clone .

You can shallow clone the repo and skip checking out files:

git clone --depth=1 --no-checkout <url/repo.git>

Test

  1. Normal clone

    git clone https://github.com/Microsoft/vscode.git
    du -h --max-depth=0 vscode/.git
    

    Result: 162M

  2. Shallow clone

    git clone --depth 1 --no-checkout https://github.com/Microsoft/vscode.git
    du -h --max-depth=0 vscode/.git
    

    Result: 11M

Getting a Git Repository, How do I clone a remote Git repository to local? Git Remote Documentation; Adding a Remote; dance2die/es6; Help me improve this~ Git command is very flexible that there might be other ways to do it much easier. Please let me know if there is a way to do it without going through all these troubles 🙂. The post Push git cloned repository to your own on GitHub appeared first on Slight Edge Coder.

git-clone Documentation, If you have a project directory that is currently not under version control and you At this point, you have a Git repository with tracked files and an initial commit. for the history of the project is pulled down by default when you run git clone . In fact, if your server disk gets corrupted, you can often use nearly any of the clones​  If you don't have an origin remote, you can add one by typing "git remote add origin" and then the URL of your repo. We've now cloned the repo and set up a remote. In the next video, we'll

Copy your Git repository and add files, Clones a repository into a newly created directory, creates remote-tracking an initial branch that is forked from the cloned repository's currently active branch. The files under .git/objects/ directory are hardlinked to save space when possible. Note that running git repack without the --local option in a repository cloned  However, if you created a Git repository based on local sources, you need to add a remote repository for other contributors to be able to push their changes to it, and for you to be able to share the results of your work. Define a remote. Create an empty repository on any Git hosting, such as Bitbucket or GitHub.

How to handle big repositories with Git, When you clone a repository, you create a connection between the Bitbucket server (which Git knows as origin) The file is untracked, meaning that Git sees a file not part of a previous commit. git commit -m "Initial commit" The git commit takes the staged snapshot and commits it to the project history. ③ Add the remote reference for the new repository. git remote add origin new-repo-url. Replace new-repo-url with the Git URL of your new repository. It goes without saying that you should have had the new repo created beforehand in your favourite Git management system. ④ Push everything to the new repository. git push --all git push --tags