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
Related
I completed MyProject1 and have uploaded it in git in fine way with commits after adding each new features. And now I'm starting MyProject2 and was trying to add the URL for the remote repository. But then I found out that I had mistakenly added the URL in Documents instead of MyProject1 folder because of which MyProject2 folder is also being tracked in MyProject1. And I'm not being able to add URL to MyProject2 but instead facing merge issues.
Is there any way to detach the track from my Document folder without deleting any of my files from Documents.
Structure is this way(I'm using Linux):
Documents
(And inside Documents there is:)
MyProject1
MyProject2
And other folders which are also being tracked.
We can manually do it with below steps
create a file .gitignore in base directory.
If MyProject1 and MyProject2 are already part of git tracking, Please run commands
git rm -r --cached MyProject1/
git rm -r --cached MyProject2/
Open the file in text editor and add below lines in file
MyProject1/
MyProject2/
Best way:
Create a .gitignore file following #Vinayagam R
Ignore file locally
Those methods won't affect other contributors working on the same remote repository:
Use update-index:
If you want to stop tracking a file at certian point.
git update-index --assume-unchanged yourDirectoryName
--assume-unchanged is the flag which means the files should not change locally. In other words, it is used when ignore files that you do not need to change locally (or should not change).
To revert it use update-index --no-assume-unchanged yourDirectoryName
Using .exclude
In your working directory edit .git/info/exclude
I created a new directory 438-healthme and cloned a repo into it.
When I index into that directory on the master branch and run a git status it lists all of my computer's files as untracked (see screenshot).
It seems like I set up git wrong a few years ago--is there a way to fix this?
You must have run git init in a folder. You need to find it and run rm -r .git.
Try again, removing that folder, and recreating it with:
git clone https://url/remote/repo 438-healthme
Then, in 438-healthme, there should be a .git subfolder, which means a git status (in the newly created 438-healthme folder) will show you files only from 438-healthme.
Suppose I have a git working directory, i.e. the directory which has a subdirectory called .git.
I wonder if the current directory matters when I run a git command.
Is it okay to run a git command
directly under the working directory
directly under some subdirectory of (subdirectory of) the working directory
directly under the parent directory of the working directory?
Consider
git commands which can take an argument which specifies some files, e.g. git add, and
git commands which doesn't take an argument that specifies some files, e.g. git pull, git push.
directly under the parent directory of the working directory?
Actually you can run it anywhere you want as long as you reference the git repo:
git --git-dir=/path/to/my/repo/.git add .
That means wherever you are (.: current folder) will be considered as your working tree. A
You can even specify your working tree:
git --work-tree=/a/path --git-dir=/path/to/my/repo/.git add .
In that latter case, you even can execute that last command anywhere you want. The '.' will be the work-tree /a/path.
Since git 1.8.5, you also have the -C option:
git -C /path/to/my/repo add .
Again, you can execute it anywhere you want, but the command will internally do a cd /path/to/my/repo first, and then execute the add .. That means the '.' will actually be /path/to/my/repo.
Finally, since git 2.5, a git repo supports multiple working trees, so you may execute your command in a folder which does not include a subfolder .git (but actually a kind of symbolic link to /path/to/my/repo/git)
It's OK to run both type of commands in both
directly under the working directory
directly under some subdirectory of (subdirectory of...) the working directory
Note, that you should use paths relative to directory where you are
You can't (by default) run any git command in parent directory. You'll get a message that you aren't in any repo.
I wonder if the current directory matters when I run a git command.
It does. git searches the current working directory for the .git subdirectory, and if it doesn't find it then it searches the parent directory, and so on until it finds it.
directly under the working directory
Yes.
directly under some subdirectory of (subdirectory of) the working directory
Yes.
directly under the parent directory of the working directory?
No, not by default. It is possible to tell git where to find the .git directory so that it doesn't search, but this is not the usual mode of operation.
Documentation on the relevant environment variables:
GIT_DIR is the location of the .git folder. If this isn’t specified, Git walks up the directory tree until it gets to ~ or /, looking for a .git directory at every step.
GIT_WORK_TREE is the location of the root of the working directory for a non-bare repository. If not specified, the parent directory of $GIT_DIR is used.
Source
git commands which can take an argument which specifies some files, e.g. git add, and
These commands need to know both where the .git directory is and the relative position of paths in the work tree.
git commands which doesn't take an argument that specifies some files, e.g. git pull, git push.
Commands like git push or git fetch need to know where the .git directory is, but don't care about the work tree. git pull does since it does a git merge which modifies files in the working tree.
I'm trying to use CVS on my linux machine for the first time for a project, and I keep hitting my head against the same brick wall.
I have created a projects directory as /home/myuser/cvsproject
I then set the environment variable for CVS as:
export CVSROOT=/home/myuser/cvsproject
I then ran the initialize for CVS as: cvs init
This created the CVSROOT folder under my projects directory.
I then created a lower level project directory, as /home/myuser/cvsproject/project1
I added these project details in the modules file at the end as
project1 project1
I am now trying to add a new file to the repository with cvs add project1/filename.txt but I get the following error:
cvs add: in directory project1:
cvs [add aborted]: there is no version here; do 'cvs checkout' first
The file is in my current directory, located in /home/myuser/cvsproject/
If I try to add the file without the project1 prefix: cvs add filename.txt I get the same error still.
I am able to check out a file in the CVSROOT directory, i.e.
cvs checkout CVSROOT/modules so CVS is definitely working.
I appreciate any help. Thanks
CVS is not decentralised, you shouldn't make your project directory the root of CVS repository. Set CVSROOT to different place where your repository will reside (that is not the same place as your project's working directory - it should be some place new, where CVS will create its structure), then add or import everything you need (don't forget to commit). If you want another working copy, you should checkout from the same CVSROOT.
it's my first using the git commands on a linux environment and I got a weird problem. I cloned a git repository and changed the file "index.html" for testing purposes. I use the following commands after that:
$git add .
$git commit - m "test"
$git push
It works fine, expect that it created a second file of the index.html, named "index.html~"why?
thank you :)
/edit: The file doesnt exist in my local repository tho..
Files with ~ are generally created you start editing the file, so I suppose you committed when your index.html was being opened/edited
linux user? use gedit or etc editor?
create .gitignore file and add string inside this file:
*~
git push does not touch your working directory, it just sends your local commits to a remote server. It is essentially a read-only operation on the local repository (just the remote-tracking refs are updated).
So git push can't be the one creating this *~ file. As said elsewhere, your text editor (e.g. Emacs) probably is.
I suggest that you ignore all *~ files by adding *~ to ~/.config/git/ignore (create the file and directories if they do not exist).