Where can I find for the location of the repos managed by Gitosis in Linux - linux

We are using Gitosis in our Linux OS server to manage our projects. One time, I mistakenly pushed the config file which contains errors and then I wasn't able to push changes or clone copies of other projects from the server anymore, including gitosis-admin itself. Now, I need to login to the server using the root user and edit the config file there.
So, when I logged on to the server I saw these files:
Then I cd into gitosis-admin:
Then I cd again into gitosis-admin:
Then I vim the config file. This is what I see:
The content is obviously not what I am expecting, because I should have other repos listed in this config file.
I also double checked with git reflog to see the commit history:
Then I thought there might be another gitosis-admin located somewhere else so I search using the command: find / -type d -name 'gitosis-admin'
This is what I got:
The two directories are the ones that I checked. And they do not match the one I have in my local computer.
I tried searching for one of our projects but still I got no result at all.
Then I thought that the root might not have access to the repo files so I switched to the git user by executing the following command:
sudo git
But still, I can't find the directory of the repos.
So now, I need to know where are the repos located so that I might find the "real" gitosis-admin there.
You might be wondering am I checking on the wrong server here. So to prove that I am not mistaken, this is a screenshot of the host address that I am connected to:
This is the remote address of the gitosis-admin git repo shown in source tree:

A typical directory would be the repositories sub-directory of the git user's $HOME directory, that is
~git/repositories
It is possible to change this location using the repositories key of the gitosis section in the configuration file, which typically is a file named .gitosis.conf in the git user's home directory.
To answer the implied question (namely which file to fix to restore gitosis access), that would be ~git/.gitosis.conf as well.
(This is all documented in the gitosis repository's readme file.)

Related

how to download a folder with multiple files from github with wget? [duplicate]

How can I download only a specific folder or directory from a remote Git repo hosted on GitHub?
Say the example GitHub repo lives here:
git#github.com:foobar/Test.git
Its directory structure:
Test/
├── foo/
│ ├── a.py
│ └── b.py
└── bar/
├── c.py
└── d.py
I want to download only the foo folder and not clone the whole Test project.
Update Apr. 2021: there are a few tools created by the community that can do this for you:
Download Directory (Credits to fregante)
It has also been integrated into the excellent Refined Github chrome extension as a button in the Github web UI.
GitZip (Credits to Kino - see his answer here)
DownGit (Credits to Minhas Kamal - see his answer here)
Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.
Original (manual) approach: Checking out an individual directory is not supported by git natively, but Github can do this via SVN. If you checkout your code with subversion, Github will essentially convert the repo from git to subversion on the backend, then serve up the requested directory.
Here's how you can use this feature to download a specific folder. I'll use the popular javascript library lodash as an example.
Navigate to the folder you want to download. Let's download /test from master branch.
Modify the URL for subversion. Replace tree/master with trunk.
https://github.com/lodash/lodash/tree/master/test ➜
https://github.com/lodash/lodash/trunk/test
Download the folder. Go to the command line and grab the folder with SVN.
svn checkout https://github.com/lodash/lodash/trunk/test
You might not see any activity immediately because Github takes up to 30 seconds to convert larger repositories, so be patient.
Full URL format explanation:
If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
If you're interested in foo branch, use branches/foo instead. The
full path looks like branches/foo/foldername
Protip: You can use svn ls to see available tags and branches before downloading if you wish
That's all! Github supports more subversion features as well, including support for committing and pushing changes.
Go to DownGit > Enter Your URL > Download!
You can DIRECTLY DOWNLOAD or create DOWNLOAD LINK for any GitHub public directory or file from DownGit-
You may also configure properties of the downloaded file- detailed usage.
Disclaimer: I fell into the same problem as the question-asker and could not find any simple solution. So, I developed this tool for my own use first, then opened it for everyone :)
Two options for this feature:
Option 1: GitZip Browser Extension
Chrome Extension, Edge Extension, Firefox Addon
Usage:
Browse any Github repository page.
Two ways to download:
Choose the items:
In default, you can double click on items or check the checkbox on the front of items.
Click download button at the bottom-right of the page.
In context menu:
Click "GitZip Download" > "Whole Repository" or "Current Folder".
Move the mouse cursor on the item and click "GitZip Download" > "Selected Folder/File".
Click "GitZip Download" > "Checked Items" after doing 2-1-1.
See the progress dashboard and wait for browser trigger download.
Get the ZIP file.
Get Token:
Click GitZip Extension icon on your browser.
Click "Normal" or "Private" link besides "Get Token".
Authorize GitZip permission on Github auth page.
Back to repo page of the beginning.
Continue to use.
Option 2: Github gh-page
http://kinolien.github.io/gitzip by using GitHub API, and JSZip, FileSaver.js libraries.
Step1: Input github url to the field at the top-right.
Step2: Press enter or click download for download zip directly or click search for view the list of sub-folders and files.
Step3: Click "Download Zip File" or "Get File" button to get files.
In most cases, it works fine, except that the folder contains more than 1,000 files, because of the Github Trees API limitation. (refers to Github API#Contents)
And it also can support private/public repos and upgrade the rate limit, if you have GitHub account and use "get token" link in this site.
If you have svn, you can use svn export to do this:
svn export https://github.com/foobar/Test.git/trunk/foo
Notice the URL format:
The base URL is https://github.com/
/trunk appended at the end
Before you run svn export, it's good to first verify the content of the directory with:
svn ls https://github.com/foobar/Test.git/trunk/foo
For a Generic git Repo:
If you want to download files, not clone the repository with history, you can do this with git-archive.
git-archive makes a compressed zip or tar archive of a git repository. Some things that make it special:
You can choose which files or directories in the git repository to archive.
It doesn't archive the .git/ folder, or any untracked files in the repository it's run on.
You can archive a specific branch, tag, or commit. Projects managed with git often use this to generate archives of versions of the project (beta, release, 2.0, etc.) for users to download.
An example of creating an archive of the docs/usage directory from a remote repo you're connected to with ssh:
# in terminal
$ git archive --format tar --remote ssh://server.org/path/to/git HEAD docs/usage > /tmp/usage_docs.tar
More information in this blog post and the git documentation.
Note on GitHub Repos:
GitHub doesn't allow git-archive access. ☹️
After trying all the answers, the best solution for me was:
GitHub's vscode based editor.
Pros:
doesn't require any extra tool like svn or API tokens.
No limit on size of content
Saves as a directory or file, and not archive.
Instructions
Go to any repo. (ex. https://github.com/RespiraWorks/Ventilator/tree/master/software)
Press . or replace .com with .dev in URL to open the repo in GitHub's internal editor
In Explorer pane (left side or press Ctrl+Shift+E), Right click on the required file/folder and select download.
In the Select Folder dialog box, choose the directory on your disk under which you want the selected file/folder to exist.
Note
I tried other solutions like in accepted answer but,
Don't want to install and learn svn only for this.
Other tools like Download Directory, Refined GitHub, GitZip, DownGit either require API tokens or cannot download large directories.
Other options
VSCode with Remote Repositories extension to open the repo and download the file/folder.
Nothing wrong with other answers but I just thought I'd share step-by-step instructions for those wandering through this process for the first time.
How to download a single folder from a github repository (Mac OS X):
~ To open Terminal just click spotlight and type terminal then hit enter
On a Mac you likely already have SVN (to test just open terminal and
type "svn" or "which svn" ~ without the quote marks)
On Github: Locate the Github path to your git folder (not the repo) by clicking the specific folder name within a repo
Copy the path from the address bar of the browser
Open Terminal and type: svn export
Next paste in the address (eg.):
https://github.com/mingsai/Sample-Code/tree/master/HeadsUpUI
Replace the words: tree/master
with the word: trunk
Type in the destination folder for the files (in this example, I
store the target folder inside of the Downloads folder for the
current user)
Here space is just the spacebar not the word (space) ~/Downloads/HeadsUpUI
The final terminal command shows the full command to download the
folder (compare the address to step 5) svn export
https://github.com/mingsai/Sample-Code/trunk/HeadsUpUI
~/Downloads/HeadsUpUI
BTW - If you are on Windows or some other platform you can find a binary download of subversion (svn) at http://subversion.apache.org
~ If you want to checkout the folder rather than simply download it try using the svn help (tldr: replace export with checkout)
Update
Regarding the comment on resuming an interrupted download/checkout. I would try running svn cleanup followed by svn update. Please search SO for additional options.
Whoever is working on specific folder he needs to clone that particular folder itself, to do so please follow below steps by using sparse checkout.
Create a directory.
Initialize a Git repository. (git init)
Enable Sparse Checkouts. (git config core.sparsecheckout true)
Tell Git which directories you want (echo 2015/brand/May( refer to folder you want to work on) >> .git/info/sparse-checkout)
Add the remote (git remote add -f origin https://jafartke.com/mkt-imdev/DVM.git)
Fetch the files (git pull origin master )
You cannot; unlike Subversion, where each subdirectory can be checked out individually, Git operates on a whole-repository basis.
For projects where finer-grained access is necessary, you can use submodules -- each submodule is a separate Git project, and thus can be cloned individually.
It is conceivable that a Git front-end (e.g. GitHub's web interface, or gitweb) could choose to provide an interface for you to extract a given folder, but to my knowledge none of them do that (though they do let you download individual files, so if the folder does not contain too many files, that is an option)
Edit - GitHub actually offers access via SVN, which would allow you to do just this (as per comment). See https://github.com/blog/1438-improved-svn-here-to-stay-old-svn-going-away for latest instructions on how to do this
2019 Summary
There are a variety of ways to handle this, depending on whether or not you want to do this manually or programmatically.
There are four options summarized below. And for those that prefer a more hands-on explanation, I've put together a YouTube video: Download Individual Files and Folders from GitHub.
Also, I've posted a similar answer on StackOverflow for those that need to download single files from GitHub (as opposed to folders).
1. GitHub User Interface
There's a download button on the repository's homepage. Of course, this downloads the entire repo, after which you would need to unzip the download and then manually drag out the specific folder you need.
2. Third Party Tools
There are a variety of browser extensions and web apps that can handle this, with DownGit being one of them. Simply paste in the GitHub URL to the folder (e.g. https://github.com/babel/babel-eslint/tree/master/lib) and press the "Download" button.
3. Subversion
GitHub does not support git-archive (the git feature that would allow us to download specific folders). GitHub does however, support a variety of Subversion features, one of which we can use for this purpose. Subversion is a version control system (an alternative to git). You'll need Subversion installed. Grab the GitHub URL for the folder you want to download. You'll need to modify this URL, though. You want the link to the repository, followed by the word "trunk", and ending with the path to the nested folder. In other words, using the same folder link example that I mentioned above, we would replace "tree/master" with "trunk". Finally, open up a terminal, navigate to the directory that you want the content to get downloaded to, type in the following command (replacing the URL with the URL you constructed): svn export https://github.com/babel/babel-eslint/trunk/lib, and press enter.
4. GitHub API
This is the solution you'll need if you want to accomplish this task programmatically. And this is actually what DownGit is using under the hood. Using GitHub's REST API, write a script that does a GET request to the content endpoint. The endpoint can be constructed as follows: https://api.github.com/repos/:owner/:repo/contents/:path. After replacing the placeholders, an example endpoint is: https://api.github.com/repos/babel/babel-eslint/contents/lib. This gives you JSON data for all of the content that exists in that folder. The data has everything you need, including whether or not the content is a folder or file, a download URL if it's a file, and an API endpoint if it's a folder (so that you can get the data for that folder). Using this data, the script can recursively go through all content in the target folder, create folders for nested folders, and download all of the files for each folder. Check out DownGit's code for inspiration.
git clone --filter downloads only the required files
E.g., to clone only objects required for subdirectory big/ of this repository: https://github.com/cirosantilli/test-git-partial-clone-big-small I can do:
git clone --depth 1 --filter=blob:none --sparse \
https://github.com/cirosantilli/test-git-partial-clone-big-small
cd test-git-partial-clone-big-small
git sparse-checkout set small
The --filter option was added together with an update to the remote protocol, and it truly prevents objects from being downloaded from the server.
I have covered this in more detail at: How do I clone a subdirectory only of a Git repository?
Tested on git 2.30.0 on January 2021.
If you truly just want to just "download" the folder and not "clone" it (for development), the easiest way to simply get a copy of the most recent version of the repository (and therefore a folder/file within it), without needing to clone the whole repo or even install git in the first place, is to download a zip archive (for any repo, fork, branch, commit, etc.) by going to the desired repository/fork/branch/commit on GitHub (e.g. http(s)://github.com/<user>/<repo>/commit/<Sha1> for a copy of the files as they were after a specific commit) and selecting the Downloads button near the upper-right.
This archive format contains none of the git-repo magic, just the tracked files themselves (and perhaps a few .gitignore files if they were tracked, but you can ignore those :p) - that means that if the code changes and you want to stay on top, you'll have to manually re-download it, and it also means you won't be able to use it as a git repository...
Not sure if that's what you're looking for in this case (again, "download"/view vs "clone"/develop), but it can be useful nonetheless...
There's a Python3 pip package called githubdl that can do this*:
export GIT_TOKEN=1234567890123456789012345678901234567890123
pip install githubdl
githubdl -u http://github.com/foobar/test -d foo
The project page is here
* Disclaimer: I wrote this package.
If you are comfortable with unix commands, you don't need special dependencies or web apps for this. You can download the repo as a tarball and untar only what you need.
Example (woff2 files from a subdirectory in fontawesome):
curl -L https://api.github.com/repos/FortAwesome/Font-Awesome/tarball | tar xz --wildcards "*/web-fonts-with-css/webfonts/*.woff2" --strip-components=3
More about the link format: https://developer.github.com/v3/repos/contents/#get-archive-link (including how to get a zip file or specific branches/refs)
Keep the initial part of the path (*/) to match any directory. Github creates a wrapper directory with the commit ref in the name, so it can't be known.
You probably want --strip-components to be the same as the amount of slashes (/) in the path (previous argument).
This will download the whole tarball. Use the SVN method mentioned in the other answers if this has to be avoided or if you want to be nice to the GitHub servers.
This is how I do it with git v2.25.0, also tested with v2.26.2. This trick doesn't work with v2.30.1
TLDR
git clone --no-checkout --filter=tree:0 https://github.com/opencv/opencv
cd opencv
# requires git 2.25.x to 2.26.2
git sparse-checkout set data/haarcascades
You can use Docker to avoid installing a specific version of git
git clone --no-checkout --filter=tree:0 https://github.com/opencv/opencv
cd opencv
# requires git 2.25.x to 2.26.2
docker run --rm -it -v $PWD/:/code/ --workdir=/code/ alpine/git:v2.26.2 sparse-checkout set data/haarcascades
Full solution
# bare minimum clone of opencv
$ git clone --no-checkout --filter=tree:0 https://github.com/opencv/opencv
...
Resolving deltas: 100% (529/529), done.
# Downloaded only ~7.3MB , takes ~3 seconds
# du = disk usage, -s = summary, -h = human-readable
$ du -sh opencv
7.3M opencv/
# Set target dir
$ cd opencv
$ git sparse-checkout set data/haarcascades
...
Updating files: 100% (17/17), done.
# Takes ~10 seconds, depending on your specs
# View downloaded files
$ du -sh data/haarcascades/
9.4M data/haarcascades/
$ ls data/haarcascades/
haarcascade_eye.xml haarcascade_frontalface_alt2.xml haarcascade_licence_plate_rus_16stages.xml haarcascade_smile.xml
haarcascade_eye_tree_eyeglasses.xml haarcascade_frontalface_alt_tree.xml haarcascade_lowerbody.xml haarcascade_upperbody.xml
haarcascade_frontalcatface.xml haarcascade_frontalface_default.xml haarcascade_profileface.xml
haarcascade_frontalcatface_extended.xml haarcascade_fullbody.xml haarcascade_righteye_2splits.xml
haarcascade_frontalface_alt.xml haarcascade_lefteye_2splits.xml haarcascade_russian_plate_number.xml
References
git-sparse-checkout-blog
git-sparse-checkout-docs
git-filter-props-docs
You can do a simple download of the directory tree:
git archive --remote git#github.com:foobar/Test.git HEAD:foo | tar xf -
But if you mean to check it out, and be able to do commits and push them back, no you can't do that.
Another specific example:
Like I want to download 'iOS Pro Geo' folder from the url
https://github.com/alokc83/APRESS-Books-Source-Code-/tree/master/%20Pro%20iOS%20Geo
and I can do so via
svn checkout https://github.com/alokc83/APRESS-Books-Source-Code-/trunk/%20Pro%20iOS%20Geo
Note trunk in the path
Edited: (as per Tommie C's comment)
Yes, using export instead of checkout would give a clean copy without extra git repository files.
svn export https://github.com/alokc83/APRESS-Books-Source-Code-/trunk/%20Pro%20iOS%20Geo
Edited: If tree/master is not there in url then Fork it and it will be there in Forked url.
git sparse-checkout
Git 2.25.0 includes a new experimental git sparse-checkout command that makes the existing feature easier to use, along with some important performance benefits for large repositories. (The GitHub Blog)
Example with current version:
git clone --filter=blob:none --sparse https://github.com/git/git.git
cd git
git sparse-checkout init --cone
git sparse-checkout add t
Most notably
--sparse checks out only top-level directory files of git repository into working copy
git sparse-checkout add t incrementally adds/checks out t subfolder of git
Other elements
git sparse-checkout init does some preparations to enable partial checkouts
--filter=blob:none optimizes data fetching by downloading only necessary git objects (take a look at partial clone feature for further infos)
--cone also speeds up performance by applying more restricted file inclusion patterns
GitHub status
GitHub is still evaluating this feature internally while it’s enabled on a select few repositories [...]. As the feature stabilizes and matures, we’ll keep you updated with its progress. (docs)
you can use git-svn in the following way.
first, replace tree/master with trunk
then, install git-svn by sudo apt install git-svn
git svn clone https://github.com/lodash/lodash/trunk/test
This way you don't have to go through the pain of setting svn, specifically for Windows users.
None of the answers helped in my situation. If you are developing for Windows, you likely don't have svn. In many situations one can't count on users to have Git installed either, or don't want to download entire repositories for other reasons. Some of the people that answered this question, such as Willem van Ketwich and aztack, made tools to accomplish this task. However, if the tool isn't written for the language you are using, or you don't want to install a third party library, these don't work.
However, there is a much easier way. GitHub has an API that allows you to download a single file or an entire directory's contents using GET requests. You can access a directory using https://api.github.com/repos/:owner/:repo_name/contents/:path that returns a JSON object enumerating all the files in the directory. Included in the enumeration is a link to the raw content of the file, the download_url parameter. The file can then be downloaded using that URL.
It's a two step process that requires the ability to make GET requests, but this can be implemented in pretty much any language, on any platform. It can be used to get files or directories.
You can use ghget with any URL copied from the address bar:
ghget https://github.com/fivethirtyeight/data/tree/master/airline-safety
It's a self-contained portable shell script that doesn't use SVN (which didn't work for me on a big repo). It also doesn't use the API so it doesn't require a token and isn't rate-limited.
Disclaimer: I made it.
Just 5 steps to go
Download SVN from here.
Open CMD and go to SVN bin directory like:
cd %ProgramFiles%\SlikSvn\bin
Let's suppose I wan to download this directory URL
https://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples
Replace
tree/develop
or tree/master with trunk
Now fire this last command to download folder in same directory.
svn export https://github.com/ZeBobo5/Vlc.DotNet/trunk/src/Samples
Just to amplify the answers above, a real example from a real GitHub repository to a local directory would be:
svn ls https://github.com/rdcarp/playing-cards/trunk/PumpkinSoup.PlayingCards.Interfaces
svn export https://github.com/rdcarp/playing-cards/trunk/PumpkinSoup.PlayingCards.Interfaces /temp/SvnExport/Washburn
Sometimes a concrete example helps clarify the substitutions proposed.
I use linux so , put this in ~/.bashrc , called even :D $HOME/.bashrc
git-dowloadfolder(){
a="$1"
svn checkout ${a/tree\/master/trunk}
}
then refresh the shell with
source ~/.bashrc
then use it with git-downloadfolder blablabla :D
It's one of the few places where SVN is better than Git.
In the end we've gravitated towards three options:
Use wget to grab the data from GitHub (using the raw file view).
Have upstream projects publish the required data subset as build artifacts.
Give up and use the full checkout. It's big hit on the first build, but unless you get lot of traffic, it's not too much hassle in the following builds.
For whatever reason, the svn solution does not work for me, and since I have no need of svn for anything else, it did not make sense to spend time trying to make it, so I looked for a simple solution using tools I already had. This script uses only curl and awk to download all files in a GitHub directory described as "/:user:repo/contents/:path".
The returned body of a call to the GitHub REST API
"GET /repos/:user:repo/contents/:path" command returns an object that includes a "download_url" link for each file in a directory.
This command-line script calls that REST API using curl and sends the result through AWK, which filters out all but the "download_url" lines, erases quote marks and commas from the links, and then downloads the links using another call to curl.
curl -s https://api.github.com/repos/:user/:repo/contents/:path | awk \
'/download_url/ { gsub("\"|,", "", $2); system("curl -O "$2"); }'
To export a directory from GitHub, replace "/tree/master/" in the directory's url with "/trunk/".
For example, to export the directory from the following URL:
https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-hibernate-portlet
run the following command:
svn export https://github.com/liferay/liferay-plugins/trunk/portlets/sample-hibernate-portlet
Our team wrote a bash script to do this because we didn't want to have to install SVN on our bare bones server.
https://github.com/ojbc/docker/blob/master/java8-karaf3/files/git-download.sh
It uses the github API and can be run from the command line like this:
git-download.sh https://api.github.com/repos/ojbc/main/contents/shared/ojb-certs
I work with CentOS 7 servers on which I don't have root access, nor git, svn, etc (nor want to!) so made a python script to download any github folder: https://github.com/andrrrl/github-folder-downloader
Usage is simple, just copy the relevant part from a github project, let's say the project is https://github.com/MaxCDN/php-maxcdn/, and you want a folder where some source files are only, then you need to do something like:
$ python gdownload.py "/MaxCDN/php-maxcdn/tree/master/src" /my/target/dir/
(will create target folder if doesn't exist)
It requires lxml library, can be installed with easy_install lxml
If you don't have root access (like me) you can create a .pydistutils.py file into your $HOME dir with these contents:
[install]
user=1
And easy_install lxml will just work (ref: https://stackoverflow.com/a/33464597/591257).
Open repo to codesandbox by replacing github to githubbox in url and on codesandbox go to file menu and Export it as a zip.
For following repo:
https://github.com/geist-org/react/tree/master/examples/custom-themes
Enter following url:
https://githubbox.com/geist-org/react/tree/master/examples/custom-themes
In codesandbox go to file menu and Export it as a Zip.

Follow symlinks in SVN

I have a linux directory (and don't need any windows checkout):
/home/me/projects/project1
In this project, I need SVN (1.8.8) to follow a symlink "link1":
/home/me/projects/project1/link1/<some_directories_and_files>
But SVN won't let me do that, it just add link1 but not its content. If I try to add its content, I get an error:
svn add link1/*
svn: E145001: Can't schedule an addition of '/home/me/projects/project1/link1/first_directory' below a not-directory node
I tried converting link1 to hard link but I can't do that either:
ln /path/to/my/linked/directory link1
ln: ‘/path/to/my/linked/directory’: hard link not allowed for directory
Any idea? How do you handle this kind of configuration? I just need to commit everything from /home/me/projects/project1 from a simple svn commit
If I understand your problem, you have:
project1/
project1/link1 -> ../../some/where/else
If you do a simple svn add link1 it adds a symlink entry to the subversion repository, but what you're trying to accomplish is getting the stuff under somewhere else into the tree.
If this is the case, then you're fighting in the wrong direction, you should make the real files and directories under link1, and make the target locations symlinks into the link1 directory. That would be a simple solution to the problem.
Another solution would be to make the location ../../some/where/else an svn location in it's own right, and make link1 an externals definition to that location. When you commit in the main directory, the externals would be committed at the same time which would achieve storing the information; however to ensure that the other location was kept in sync, you would have to make sure to update it to the same version as the stored data.
In my case, on my desktop, I have a settings directory:
$HOME/settings
This is a checked out copy of a directory containing .bashrc, .profile, .vimrc, .vim, etc. files and folders from an svn repo. All my profile files and directories were symlinks into this folder, so for example .profile -> settings/.profile, etc. When I make changes, they are reflected in the svn tree, which I can commit back to in order to ensure that I don't lose my config settings when I go to another system.
If you really want svn to follow symlinks as hardlinks (You can't make directory hardlinks because it would be a bad thing™), then you'll have to hack the svn client source so that it did what you wanted; but this would be a maintenance nightmare.
You could get away with making the symlink into a bind mount point directed at the target, but that has it's own issues - you would need to be root to accomplish this, and it ends up leaving funny entries in your /proc/mounts to accomplish this:
mount --bind /absolute/path/to/some/where/else project1/link1
Bind mounting does not work when mounting to inside the svn tree since the working copy format changes introduced by svn 1.7 - svn operations attempt to move files from .svn/tmp to the target folder, which would be a cross device link. The workaround in this case is to go from the inside out, i.e.:
mount --bind project/link1 /absolute/path/to/somewhere/else
With the change in the svn working copy format of a single .svn folder for the checked out tree, you will need to perform all subsequent operations from the true svn location, as it won’t work from the bind mounted folder, on the assumption that you have not mounted the entire checked out tree at that target location.

Set SVNs working copy to public_html on cPanel server with external repos

When I do php programming, I tend to edit in-place on the (development) server (cpanel VPS, not local) via a text editor that has built in sFTP. I like this because there isn't 100 thinkgs you have to do to "publish" the changes, you save (via FTP) and reload the page.
I want to get the source into SVN mostly so I can track other people's edits.
I currently use tortoiseSVN on my windows machine to access hosted SVN repos (csvdude/codison) for non web projects so I'm familiar with that. Linux SVN, not so much.
My thought here (open to other ideas) is that I want the public_html folder on the server to be the working copy (Is there a problem with this?). People can make edits as they would via sFTP and then the working copy would be committed to the external SVN repo, possibly on a late night cron..hoping I can set it up to auto-add and commit.
So aside from thoughts on the idea, I'm curious how to set up the linux svn client to commit to external repos a la tortoiseSVN. It seems all the tutorials I see set up a local repo.
Additionally I'm worried when I check out with public_html dir as the working copy that it will overwrite everything. (yes I have backups...)
Any input or suggestions would be awesome.. Thanks.
I created a new repo on my hosted SVN service.
I manually created a public_html folder using the repo browser.
On the cPanel server:
cd /home/[account]/
svn checkout https://svnservice.com/my_repo/public_html
I set up an ignore list for directories in public_html I didn't want in the repo.
Then you can add files and directories to the repo
cd public_html
svn add [directory] // adds directory for commit
svn add --force . // adds all new files without ignoring the ignore list
In hindsight, I think the import command would have done something similar, I just didn't quite understand it enough.
This is a useful command as well:
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % // removes files from repo that no longer exist in the working copy
EDIT: One thing I should mention is to make sure your .htaccess blocks access to .svn directories or it could expose source code.

Bare Git repo cannot add files or commit files

So I have been plagued with this weird git problem that myself and a few other developers have not been able to solve. Here it is:
I created a bare repo for managing website changes using git on test server.
For this example the repo is here: /home/website/website.git
The website public root would be here: /home/website
I created the repo by doing this command: git init --bare
inside the git repo directory "website.git"
Next I have my local repo on a machine elsewhere. This is a standard git repo. I build the site get it ready to deploy. When its ready I push it to the bare repo. From my local repo.
There is a post-receive hook that checks the latest file tree out into the public root of the website. So when I change things on the local repo and test them in the localhost environment, once satisfied I can push them to the live server.
Here is the problem I face:
I can push fine. No issues. All works as expected. Code gets checked out to public root. Everybody is happy and goes on with their life.
BUT!!!:
The site is a CMS site. Users log in to it and upload things. Files get created on the public root of the website which is the GIT_WORK_TREE.
So NBD right?! I can just commit the files every now and then from the live bare repo and pull them back to my local environment like I have before. So I log into SSH on the server. Navigate to /home/website/website.git
Then run this command:
GIT_WORK_TREE=/home/website/ git add ../
I get this mess:
error: unable to create temporary sha1 filename ./objects/cb: No such file or directory
error: error_log: failed to insert into database
error: unable to index file error_log
fatal: adding files failed
I have done this before on other servers and it worked fine from what I remember. So I was like WTF, must be something strange on this server. I went to another server I have and replicated the EXACT same steps. Got the EXACT same problem. So now I fear I am loosing my sanity and maybe these previous git experiences are all made up in my head.... *Well, lets not go that far yet.... :)
Maybe somebody can help me out here. I have used git plenty and can't seem to crack this one.
Oh, some other maybe useful specs:
running CENTOS 6.2
I double checked all permissions. I even tried changing everything to 777 recursively just to make sure Im not loosing it somehow. Made sure all the files are owned by the correct user. chowned recursively. I also tried the standard solution to this problem which is described here: https://answers.atlassian.com/questions/132671/git-commit-fails-with-sourcetree-error-unable-to-create-temporary-sha1-filename-git-objects-d8-file-exists
That didnt work either. Not sure where to go from here.
PLEASE HELP ME!!!!
I feel like Linus is playing cruel tricks on me right now.
You have a bare git repository in /home/website/website.git which is inside of a git repository in /home/website? And then you try to trick the bare git repository into having a working tree using GIT_WORK_TREE?
Maybe it is worth understanding this setup but only if you intend to be a git developer. As you are a user focused on delivering website functionality, I suggest using a standard git setup.
Move the bare git repository elsewhere:
$ mkdir /home/repo
$ mv /home/website/website.git /home/repo/website.git
$ cd /home/website
$ git remote set-url origin /home/repo/website.git
I got the solution. This is it. I was running the above command from the git repo.
Turns out the command should be run from the work tree and altered to look like this:
GIT_WORK_TREE=/home/website/ git --git-dir="./website.git/" add ./

How could I recover my git-daemon repositories

I had a Gitorious install that got old and it is clear now that it is not coming back. I want to recover the repos (mainly the wiki repos) from the repository. I do not want to repeat the long and painful process of setting up Gitorious again, just to get some wiki back out of it...in fact I'd like to clean up the old install soon (remove it). Although, when it was running it was awesome!
I still have the database for gitorious, so I know which .git files I want and where to find them.
I was attempting to setup git-daemon (I'm on a Linux (ubuntu) setup), but I am not having much luck. I was hopeful that maybe I could just copy the 'foo.git' file somewhere and clone it.
Currently my .git files are in user git's home folder. No problem moving them though, but I'm not sure how to go about this.
I have git daemon running, but it 'hangs up unexpectedly' if I try to connect via 'localhost', all the repos also have my 'export-ok' file in them too. I can connect accross my LAN and clone any other git initialized directory via ssh, could that help me?
Can I just copy the foo.git (more like a f13f9ed412591ce72f7b3cb793605e93ce.git) file to maybe a git initialized repo and work with it there? Is there a git tool that I could use to expand the .git file? <-- I'm sure Git would be the tool right?
The .git is a folder and not a file and git repos are lightweight in that it is just files and folders. You can copy your repo to wherever you want.
Since you said localhost, if you want you can even clone the repos with git clone /path/to/repo.git and work on the cloned repo. You do not need the daemon or anything else to be running.

Resources