LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copy whole file tree (with everything) (https://www.linuxquestions.org/questions/linux-newbie-8/copy-whole-file-tree-with-everything-4175524266/)

KansaiRobot 11-04-2014 12:11 AM

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

gdejonge 11-04-2014 12:25 AM

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

evo2 11-04-2014 12:28 AM

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.

KansaiRobot 11-04-2014 12:49 AM

Quote:

Originally Posted by evo2 (Post 5264178)
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.

Well, as I explained previously I used cp -r and I apparently got the whole thing copied. But when I tried to build it some files were not found apparently. I imagine that some necessary links were not copied adequately and that generates the error since when I untar the original it worked without problem.

evo2 11-04-2014 12:52 AM

Hi,
Quote:

Originally Posted by KansaiRobot (Post 5264186)
Well, as I explained previously I used cp -r and I apparently got the whole thing copied. But when I tried to build it some files were not found apparently. I imagine that some necessary links were not copied adequately and that generates the error since when I untar the original it worked without problem.

Links can preserved using the appropriate options with cp. For example use "cp -a". Same is true with tar and rsync. However, I sill think you should investigate using git.

Evo2.

propofol 11-05-2014 10:10 AM

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/

KansaiRobot 11-06-2014 12:08 AM

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 :)

KansaiRobot 12-10-2014 01:35 AM

Quick question:

what is the best graphical tool to use Git (which is command based right).

Which do you prefer and why?

gdejonge 12-10-2014 07:54 AM

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,

KansaiRobot 12-10-2014 10:33 PM

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.

KansaiRobot 12-15-2014 11:20 PM

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

ndc85430 12-16-2014 12:37 AM

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).

veerain 12-16-2014 11:19 AM

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.