How can I access the trunk directory of a new Subversion repository? - linux

I created a Subversion repository along with branches, tags and trunk directories with:
svnadmin create file:///home/user/public_html/repo/myrepo
svn mkdir file:///home/user/public_html/repo/myrepo/tags -m "tags created"
svn mkdir file:///home/user/public_html/repo/myrepo/branches -m "branches created"
svn mkdir file:///home/user/public_html/repo/myrepo/trunk -m "trunk created"
After doing this, why can't see my trunk directory in /home/user/public_html/repo/myrepo? When I run the command svn ls -R file:///home/user/public_html/repo/myrepo/, I can see it.
I need to see the trunk directory because I want to create a symlink to work on the app online:
ln -s /home/user/public_html/repo/myrepo/trunk /home/user/public_html/dev/
How can I make the trunk folder visible?

The repository directory created with svnadmin create is essentially a database where Subversion stores information about files and their versions.
To access the files contained within the repository, you need to check out a working copy using the svn checkout command. For example, the following command will check out the repository you created to a directory named /home/user/public_html/working:
svn checkout file:///home/user/public_html/repo/myrepo /home/user/public_html/working
After checking out the repository, the /home/user/public_html/working directory would contain trunk, branches and tags subdirectories and you could then create a symlink:
ln -s /home/user/public_html/working/trunk /home/user/public_html/dev/
For further information, I'd recommend reading the Version Control with Subversion book (in particular the Fundamental Concepts and Basic Usage chapters).

Related

svn import is giving error

i am working on svn project and i am totally newbie.i am learning SVN from tutorialspoint. i have create repository successfully. and created directories for trunk, branches and tags using following commands
mkdir /tmp/svn-template
mkdir /tmp/svn-template/trunk
mkdir /tmp/svn-template/branches
mkdir /tmp/svn-template/tags
now i want to import that dir to my repository using following command
svn import -m 'Create trunk, branches, tags directory structure' /tmp/svn-template/
but it gives me an error "
svn: E205000: Try 'svn help' for more info
svn: E205000: Invalid URL '/root/tmp/svn-template'
"
please help me guys
You forgot to specify the last argument, your repository URL.
For example:
svn import -m 'Create ...' /tmp/svn-template/ http://svn.myserver.com/repo/svn-template/
Be aware that your local copy will not be under version control after that. You must make a checkout of a working copy in another directory.
cd /somewhere/else
svn checkout http://svn.myserver.com/repo/svn-template/
change the SVNPath in /etc/httpd/conf.d/subversion.conf
to "SVNPath /var/www/svn/your_project_name"
cd /var/www/svn
Now import the dir /tmp/svn-template
svn import /tmp/svn-template/ http://ip-address/svn/ -m "Create trunk,branches and tags directories"

Git ignore and changing the history (on Windows)

I've already read several posts about this here (like Git ignore & changing the past, How to remove files that are listed in the .gitignore but still on the repository?, and Applying .gitignore to committed files), but they have several problems:
Commands that only work on Linux.
Incomplete commands (like the first post I've linked to).
Only for one file.
I have pretty much no experience with Git so I was hoping for some help here.
What I'm basically trying to do is rescue one of my projects history. It's currently Hg and I converted it to Git with Hg-Git (all very easy) and it includes the history (great!). However, I also added a .gitignore file and added several new files & folders that I want completely gone from the history (like the bin and obj folders, but also files from ReSharper). So I'm looking for a way to apply the .gitignore file to all of my history. The commands should work on Windows as I have no intention of installing Linux for this.
No need to add the .gitignore in the history (there is no added value to do it), just add it for your future commits.
For the remove of files and directories in your history, use bfg-repo-cleaner which is fast, easy and works very well on Windows (done in scala).
It will do the job for you!
This is working for me:
Install hg-git.
cd HgFolder
hg bookmark -r default master
mkdir ../GitFolder
cd ../GitFolder
git init --bare
cd ../HgFolder
hg push ../GitFolder
Move all files from GitFolder to a '.git' folder (in this GitFolder) and set this folder to hidden (not the subfolders and files).
cd ../GitFolder
git init
git remote add origin https://url.git
Copy all current content (including .gitignore) to GitFolder.
git add .
git commit -m "Added existing content and .gitignore".
git filter-branch --index-filter "git rm --cache d -r --ignore-unmatch 'LINES' 'FROM' 'GITIGNORE'" --prune-empty --tag-name-filter cat -- --all
git rm -r --cached .
git add .
git gc --prune=now --aggressive
git push origin master --force
There is probably an easier way to do this and it might not be perfect but this had the result I wanted.

Git clone without including top/parent folder

We have a repo in git where the project is contained in a folder called Project. We'd like to be able to release the code to a production server, by cloning the repo, without including the "Project" folder, but with everything below it. Is this possible? The destination directory name is /var/www, which is unrelated to anything in the project. Unfortunately I can't just do a symbolic link because of the nature of our hosting provider (which we'll change soon).
My answer take the assumption that you have a git repository whose content is the following:
/.gitignore
/Project
/Project/index.php
/ProjectB
/ProjectB/pom.xml
If you don't need history at all in that copy of your repository, there is the git archive command which can do what you want except its output its data in tar or zip format:
git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
[-o <file> | --output=<file>] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[<path>…]
Like:
git archive --format=zip --remote=git#foobar.git master -- Project | unzip
However, the git clone command does not accept a repository path, and I think it's not really git like to export only a tree view of some branch. You would probably need a submodule making Project an independent git repository, or like the git archive example, get only what you want but without versioning (which can be questionable on a production server).
Instead, you can do that:
Clone your repository to whatever path, say /opt/foobar.
Create a symbolic link of /opt/foobar/Project in /var/www.
Or reference the /opt/foobar/Project in your apache configuration (to avoid the symlink) instead of plain /var/www.

can git be run with less file permissions than the files it tracks?

here is the situation: i want to use git to track a directory of preference files that are owned by root.
it would be nice if git commands that don't modify the files (like git status and git diff) can be run as the user (without sudo).
through the following steps, i've created a repo that seems to function in a reasonable manner:
sudo mkdir .git
sudo chmod <user>:<group> .git
git init
git add .
git commit -m "initial commit"
i can run git status and git diff as the user. git checkout ... and git reset ... fail as the user, but seem to run fine when prefixed with sudo.
this seems perfect: no sudo needed to get into the repo and take a look at what's gone on, but to change the tracked files requires an extra level of effort, as it should for system files.
the question is: will this cause me any problems with how git is reading and writing files inside the .git directory? will any commands i need sudo to run end up creating things inside .git with root permission that will then cause problems trying to run commands that don't modify the tracked files as the user?
thanks and advance for any answers.

SVN checkout the contents of a folder, not the folder itself

I'm fairly new to linux and svn. I'm trying to checkout the trunk folder of a project into my public_html directory using this command (while in public_html):
svn checkout file:///home/landonwinters/svn/waterproject/trunk
The waterproject directory contains the files from untarring a base install of drupal.
It checks out fine, except all the files are in public_html/trunk instead of just being in public_html.
I don't know the command to move all the contents of trunk up to public_html and rm trunk, but I think I could figure that out relatively easily. I just want to know if I can just check out the contents of a folder, without the folder itself.
Just add a . to it:
svn checkout file:///home/landonwinters/svn/waterproject/trunk .
That means: check out to current directory.
svn co svn://path destination
To specify current directory, use a "." for your destination directory:
svn checkout file:///home/landonwinters/svn/waterproject/trunk .
Just add the directory on the command line:
svn checkout svn://192.168.1.1/projectname/ target-directory/
Provide the directory on the command line:
svn checkout file:///home/landonwinters/svn/waterproject/trunk public_html

Resources