![]() ![]() ![]() Move all the files in the current directory into service-worker/sw-test.NOTE: Do not yet run any of the commands below at this stage. ![]() Now that we know how and why we want extendedglob enabled, we move on to using our new powers. NOTE: You might also want to disable it after completing your move operation. It is not enabled by default because it could cause problems if file names contain some of the extendedglob patterns, such as ^. We, therefore, need this negation syntax. We want to tell the operating system to move everything into our new subfolder except the subfolder itself. It will “work,” but you will see an error message like this: mv: rename service-worker to service-worker/sw-test/service-worker: Invalid argument If you do the following, for example: mkdir service-worker Why do you even have to do this, you may ask? Without this, you will not be able to use the negation operator I use in the above move command, which is the crux of the whole thing. With bash, you can achieve the same using the following command: shopt -s extglob On older versions of ZSH, you use the setopt and unsetopt commands. To enable extendedglob, I used the following command: Depending on your shell, the instructions below may differ.įor new versions of ZSH, you use the set -o and set +o commands to enable and disable settings. I am on a Mac using ZSH (since macOS Catalina, this is now the default shell). To spare you the trouble, here is what I had to do.įirst, a note. How to move all files in current folder to subfolder?.How to move all files in a folder to a sub folder in zsh w/ Mac OS X?.I finally stumbled upon two StackOverflow threads that brought me to the answer. However, none of the initial set of options quite met my needs. I read many StackOverflow threads, blog posts, and manual pages for the different commands with varying amounts of success. While the end goal seemed simple, I am pretty sure I grew a small animal’s worth of grey hair trying to figure out how to make that last move command work. How to exclude subdirectories when using mv The next section explains why we need it and how to enable it. The above command is a little more complex than you might think. To do this, we will make use of the move ( mv ) command: With this in place, I simply need to move everything in the root directory to the subdirectory. The first step is to create our new subdirectory. To get started, I need to clone the repo we want to merge into dom- examples. This will allow me to safely merge it into dom-examples as everything is contained in a subfolder already. What do I mean by that? I need to create a new directory in the root of the sw-test repo called service-worker/sw-test and move all relevant files into this new subdirectory. Then it hit me! I need to prepare the service worker repo to be moved. I searched around some more to see if anyone else had run into this same situation but did not find an answer. With the current setup, I could continue from the git remote command, but I wondered if the current directory contained files or folders that would conflict with those in the service worker repository. Merge pull request #142 from mdn/sideshowbarker/webgl-demo-add-playsInline-drop-autoplay Merge pull request #143 from mdn/sideshowbarker/webgl-sample6-UNPACK_FLIP_Y_WEBGL Running git log on this repository, I see the following commit history: commit cdfd2aeb93cb4bd8456345881997fcec1057efbb (HEAD -> master, upstream/master) step as my target repository already had some history, so I started as follows: git clone I could skip everything up to the git remote. # Merge the files from old_a/master into new/master # Add a remote for and fetch the old repo # Before we do a merge, we need to have an initial commit, so we’ll make a dummy commit This is how Eric describes the first steps: # Assume the current directory is where we want the new repository to be created For the experiment, I used the sw-test repository that is meant to be merged into the dom-examples repository. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |