Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting-up local git repository

I am a fan of using GitHub as my project file repository. But it interest me more if I am able to create a repository on this computer on a different directory path. Then clone that create repository on my new working directory.

I was planning to make a GitHub locally. I've been searching about this and many return that I should use gitolite and many more instead. The problem I am using Windows and I want to do all the steps using command line.

What command lines should I enter to create a repository on a different directory other than the working directory and be able to clone that repository to other terminals within the local network.


LINKING TERMINAL to Windows Host

I have created a repository directory pathed to Users\username\GIT\project.git. I am trying to link my terminal using the command line git clone file://{IPv4 server address}/Users/username/GIT/project.git returns

fatal: '/{IPv4 server address}/Users/username/GIT/project.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

How can I resolve this? I my host is running on Windows 7 and my connecting terminal(s) will be using Ubuntu 12.04 LTS and MacOS Mavericks.


UPDATE TRACK

  1. Updated my question body. I don't know what steps should I follow.
  2. Inserted LINKING TERMINAL to Windows Host question for repository sharing over local network.
like image 386
David B Avatar asked Nov 07 '13 15:11

David B


People also ask

Where should I put my local Git repository?

As the git repository is contained inside your work directory, just place the work directories wherever is most convenient.

What is local Git repository?

A Git repository is the . git/ folder inside a project. This repository tracks all changes made to files in your project, building a history over time. Meaning, if you delete the . git/ folder, then you delete your project's history.


2 Answers

Maybe you're asking simple way to create git repo and local clone ?

  1. Create git repo using git init --bare
  2. Clone from other place using git clone --local /path/your/local/repo/

For local network, windows share or other file share may work.

But, the simple way just work, not best or suitable way. there aren't pull request, issue track, privilege control feature on GitHub. For manage git commit or other complicated work, you need a manage system, such as gitolite, gerrit, some may not work on windows system.

If you only need a free private repo, you an use bitbucket.

Clone from windows share:

git clone file:////{IPv4 server address}/share_name/path_to_your_.git_dir

On host computer, you must share repo dir with a 'share_name', eg: parent dir of repo.git

See:

  • GIT clone repo across local file system in windows
  • How to git clone a repo in windows from other pc within the LAN?
  • Git on a Windows Lan
like image 127
Fwolf Avatar answered Oct 14 '22 15:10

Fwolf


If I read your problem statement correctly, You can simply clone a local git repo into another folder by using the --local switch on the clone command like this

git clone --local /git/source_repo/project /home/username/workdir/project

where

/git/source_repo/project is the safe copy of the repo (call it your personal GitHub if you like).

and

/home/username/workdir/project is your working folder. It can be any folder where you want to make frequent commits

Switches explained:

--local

When the repository to clone from is on a local machine, this flag bypasses the normal "git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under .git/objects/ directory are hardlinked to save space when possible.

If the repository is specified as a local path (e.g., /path/to/repo), this is the default, and --local is essentially a no-op. If the repository is specified as a URL, then this flag is ignored (and we never use the local optimizations). Specifying --no-local will override the default when /path/to/repo is given, using the regular git transport instead.

To force copying instead of hardlinking (which may be desirable if you are trying to make a back-up of your repository), but still avoid the usual "git aware" transport mechanism, --no-hardlinks can be used.

--no-hardlinks

Optimize the cloning process from a repository on a local filesystem by copying files under .git/objects directory.

see documentation for more details

Update 1:

For setting up a Git Server on Windows, you can try this commercial (open source) software called GitStack.

Useful GitStack resources:

  1. GitStack Installation Instructions
  2. Link to source code of GitStack on Github
like image 36
Litmus Avatar answered Oct 14 '22 14:10

Litmus