copy whole file tree (with everything)
Hello everybody
I have a very simple question and **yet** searching in the internet the responses are many and some even don't work at all. The question is: How do I copy an entire file tree, meaning, the folder, its subfolders, all files contained in them and all links, in other words everything from one place to another?? simple answers like "use cp -r" apparently do not work.. Thanks a thousand for your answers Kansai P.S> The question finished above,Just some background in case you want to know. I am developing using the source code of the kernel and userland. So far no problems. I put it somewhere, configure it, make my changes , make it and there I have solution A. But lets say I want solution B over solution A. ( I dont want to lose A) so my idea is to copy ALL the files I have been working on on another place and start on B there. I tried cp -r and it apparently copied all but when I tried to rebuild it showed errors, files not found etc. So instead of copy I downloaded again the source code , made all my changes in solution A and then solution B and it built. But I cant be doing this forever! there must be some way to copy all my previous work some other place. Thanks a lot |
This where version management tools (like git or subversion) come in.
With git you just start a new branch for your modifications. So you would create a branch modA and a branch modB. After that you can easily switch between the two branches. A good place to learn about using git. Cheers |
Hi,
what do you mean by "do not work"? If you can answer that we can probably tell you how to achieve what you want. Tools that spring to mind include tar and rsync. However since you are working with source code, and in particular the Linux kernel, I strongly suggest you use git. Evo2. |
Quote:
|
Hi,
Quote:
Evo2. |
How about rsync?
rsync -aHAXxv /source/ /destination/ The '-x' option is just to keep it from following links. To update a pre-existing copy, you may need to add '--delete'. I have used this to clone systems to new smaller ssd drives where 'dd' would not have worked: Code:
rsync -aAXxv --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found/*} / /mnt/destination/ |
Thank you
I am following your recommendation and checking Git. I still havent figure it out entirely how can I use this for my goals but on my way. Git doesnt store an entire copy of all files, does it? Only snapshots of what I have modified?? I basically modify only one or two files every time I work on something, does that mean the rest of files will be just referenced? pointed at? back to reading :) |
Quick question:
what is the best graphical tool to use Git (which is command based right). Which do you prefer and why? |
Hi,
Asking what tool is the best is asking for a flamewar to start. ;) Personally i use gitk (should come with git itself), which is a viewer to look at the latest changes. Another simple tool is git-gui (should also come with git) to do basic maintenance on a git repo. Besides that, several ide's have git support build-in. Look here and here for some more info. Cheers, |
Thank you and sorry didnt intend to
well I installed gitg. So far so good, I can see a lot of info there and it installed without any problems. |
Question:
I have already practiced some about Git. The commands, stuff. Now, I know that for example for a programming project in C you stage the source files (.c and .h) and pretty much ignore anything generated (.o, etc) So far for theory I understand. Now I want to apply this to my real problem. Which is I downloaded the kernel and the userland source files (linux). I am going to use menuconfig to set some options and then build this into some image files to burn into my device. Now the question is, which files should I stage?? or should I just stage the whole two directories that I downloaded (kernel and userland) I realize that once I make the image files a lot of object files are going to be generated Thank you for your help |
The staging area is for changes you want to commit to the repository, so if you make changes to a file, then stage it and commit. After committing, if you need to move back to the state before the commit, you can do so (take a look at git reset).
|
Use:
cp -a /path/directory1 /path/directory2 or cp -dpr /path/directory1 /path/directory2 Also while buiding linux kernel you can put built object files in other directory. Untar the kernel sources and cd to it and type make help |
All times are GMT -5. The time now is 09:12 PM. |