git mv rename all files and folders to capitalize first letter - reactjs

I am renaming all my component names and folders. All of them start with a small letter. I am capitalizing them. The way I am currently doing is for the folder names I am writing
git mv folder test
git mv test Folder
as for the files directyl
git mv file File
I have a folder that contains around 50 folders and 200 sub-files. Can I automate this? I need to capitalize all them with git mv so that Github detects the changes. I use windows 10.

Of course there are ways to automate it. Since you're apparently a JavaScript dev, you could look into the Node.js APIs;
fs.readdir to read each name in a directory
child_process.spawn to run git mv ... ...

Related

GitHub does not let me to access subfolder in remote repo [duplicate]

I have recently pushed to github, and see a white arrow on one of my folders.
and when i click on the folder, it does not open it. On my local machine, it has contents, but in github i cannot access them. What does this mean?
Symptom
Check if locally you have a .git/ sub-folder under that folder.
Cause
That would mean the folder (locally) is a nested Git repository, whose tree SHA1 is recorded as a "gitlink" (gray folder with straight white arrow)
What you would then see on GitHub is that gitlink: SHA-1 of the object refers to a commit in another repository, represented by an empty folder name. It is a nested Git repository.
If you see a folder # xxx, then it is a submodule entry, meaning your own repository has a .gitmodules in it, which records, in addition of the gitlink, the actual URL of the remote repository.
It represents the object name of the commit that the super-project expects the nested submodule's working directory to be at.
In both cases (white arrow with a folder name, or white arrow with folder # xxx, folder name and version), it is a Gitlink represented a nested Git repository: a placeholder for another Git repository, hence an empty folder. But in the second case, that empty folder would be referenced/visible in a special .gitmodules file.
Solution (to remove the white arrow)
In order to restore that folder content:
submodule:
A git clone --recurse-submodules would restore the content of that submodule in your local repository (as opposed to a nested Git repo, where its URL is not recorded, and the content of the folder would remain empty)
The white arrow would remain on the remote repository, with folder # version displaying what SHA1 of the submodule repository is referenced by your project.
Nested Git repository:
Alternatively, you could, if you don't care about the history of that folder, delete locally its .git subfolder (assuming it is not a submodule, meaning it is not referenced in a .gitmodules file in your main repository), add, commit and push.
The white arrow would then disappear, and you would be able to access that folder content on GitHub.
Then you would need to delete the gitlink entry:
git rm --cache client_folder
# without a trailing slash:
# not client_folder/ but client_folder
Finally, you can add, commit and push that folder content.
The arrow may mean that is a submodule.
You could try:
git add yourfolder
If that results in an error like:
xxx submodule xxx
appears, you may try this:
git rm --cached yourfolder
Then, you could successfully run:
git add yourfolder
On your machine, if you navigated to the directory with the arrow and tried to view hidden files, you'd see a .git folder, indicating that it is a repository. This means that it is a repo contained inside the outer repo that you had pushed to GitHub.
The easiest way to get rid of the arrow and start seeing your files properly (in my opinion) is by deleting the .git folder. That way, it ceases to become a git repo and is a regular folder once more.
Now when you push to GitHub, you can normally access the folder and view all its contents.
If you want to remove a submodule from the git config files, Follow this, remember that if you DON'T want to delete the local directory of that submodule, DON'T do Step X:
Delete the relevant section from the .gitmodules file.
Stage the .gitmodules changes git add .gitmodules
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Run rm -rf .git/modules/path_to_submodule (no trailing slash).
Commit git commit -m "Removed submodule "
(Risky)Step X :- Delete the now untracked submodule files rm -rf path_to_submodule
In my case:
git rm --cached portal
ls
git status
git add --all
...
for me, the history of changes in the subfolders were no longer important
start by removing .git from the subfolder
git rm --cached myfolder
git add myfolder
git commit -m "making myfolder available"
git push
It's due to the .git file in some of your subfolders. If you cannot find it then follow these steps....
Click file option Click this image - 1
Go to Preferences , then click settings Click this image - 2
Look for text editor, then click files Scroll down to check .git in Exclude
section. Click this image - 3
If .git is present, then remove it.
Now you will find .git folder in your main or sub folder....delete it and upload the folder to GitHub.
THIS WORKED FOR ME !!
Go to your project folder.
Go to "View" from the nav bar, go to "Show" and check "Hidden Items".
Delete all the ".git" folders from your project.
Initialize new or existing repo again and push your code.

fatal: in unpopulated submodule

I am quite new to github and I am trying to find a solution to a current problem that I am having. I will go through my process step by step:
First I created a new folder named [project name]
Next I used these commands:
cd [project name]
git clone [remote project from github url]
So far I have created a folder and cloned a project that my group is working on in github.
Next, I went inside that folder and created an angular project with
ng new [angulartest]
This will create all the components of my angular test into the same folder that is the clone of the one from github.
Finally, I pushed the new angular test on github with
git add [angulartest]
git commit
git push
What happens is that it only pushes the folder [angulartest] but none of its contents (even though there are contents in it). When I try to pull from its contents, I still just get an empty folder in return.
When I try to enter that folder and add each element of the contents, using these steps:
cd [angulartest]
git add e2e, src, nodemodules, etc
git commit
git push
It gives me the following error (even when I try to add each element individually):
fatal: in unpopulated submodule [angulartest]
I was wondering if it was a problem with my git syntax, the angular project, or the way I tried to clone the project. That way, I know which direction I want to be headed when looking for a solution.
It seems like, you may have removed the .git folder. In that case you can try
git rm --cached angulartest -f
git rm --cached . -rf
Stealing from anlijudavid's comment which was the actual answer for me on macOS with zsh.
Adding -r based on Richard Collette's comment to this answer.
The root cause of this error in my case was that I have a subdirectory with its own .git folder inside. When I issued the git add --all command, I got this same error
Here's how I resolved the issue
Remove all .git folder inside the sub directory causing the error
cd to the main directory
git rm --cached sub_directory_name -f
git add --all to add the subdirectory and contents, recursively
git status to verify that the items are added
I almost got a headache with this error but thanks for the previous answers, a combination of those worked for me.
Here's what I did
Make a copy of the 'submodule' directory somewhere outside of the repository (e.g. your desktop)
Delete the submodule directory from your repo
Commit the repo
Go into the copy you made of your submodule directory, delete .gitignore file and .git directory
Copy the submodule directory back into your repo and commit
This meant I lost the commit history of the submodule but at least it fixed the issue of my files in the submodule not going to git!
If we cloned from third party repository we got this " fatal: in unpopulated submodule 'submodule name' " error.
This error fix for me using
git rm --cached <submodule name> -f
Also you can remove .git folder manually then you can try to git add
I got the same error when I had a subdirectory in my local repo, had deleted the .git to solve different issue, and then tried to add an updated html file to my repo.
I went to github and uploaded the file using their GUI. Now I can see that everyhting matches and git status shows no issues.
Had the same issue when trying to push a new react-app folder to git.
Unfortanately, I overlooked the ".gitignore" files in the folders.
First check for files:
find | grep -w ".gitignore" | xargs ls -lh
After that:
find | grep -w ".gitignore" | xargs rm -fr

Remove a file from multiple archives?

I have 1000+ ePub books on my Ubuntu machine.(I know they are not exactly archives, but I can open them using Archive Manager). I want to delete a file stylesheet.css from all the ePubs. I don't wanna edit each epub individually. Is there any way to accomplish this?
Run this script in the directory containing epubs:
for f in *.epub; do zip -d "$f" stylesheet.css; done
zip has to be installed for this. It can be installed using
apt-get install zip

Download from gitHub [duplicate]

The command git clone git#github.com:whatever creates a directory named whatever containing a Git repository:
./
whatever/
.git
I want the contents of the Git repository cloned into my current directory ./ instead:
./
.git
Option A:
git clone git#github.com:whatever folder-name
Ergo, for right here use:
git clone git#github.com:whatever .
Option B:
Move the .git folder, too. Note that the .git folder is hidden in most graphical file explorers, so be sure to show hidden files.
mv /where/it/is/right/now/* /where/I/want/it/
mv /where/it/is/right/now/.* /where/I/want/it/
The first line grabs all normal files, the second line grabs dot-files. It is also possibe to do it in one line by enabling dotglob (i.e. shopt -s dotglob) but that is probably a bad solution if you are asking the question this answer answers.
Better yet:
Keep your working copy somewhere else, and create a symbolic link. Like this:
ln -s /where/it/is/right/now /the/path/I/want/to/use
For your case this would be something like:
ln -sfn /opt/projectA/prod/public /httpdocs/public
Which easily could be changed to test if you wanted it, i.e.:
ln -sfn /opt/projectA/test/public /httpdocs/public
without moving files around. Added -fn in case someone is copying these lines (-f is force, -n avoid some often unwanted interactions with already and non-existing links).
If you just want it to work, use Option A, if someone else is going to look at what you have done, use Option C.
The example I think a lot of people asking this question are after is this. If you are in the directory you want the contents of the git repository dumped to, run:
git clone git#github.com:whatever .
The "." at the end specifies the current folder as the checkout folder.
Go into the folder.. If the folder is empty, then:
git clone git#github.com:whatever .
else
git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master
Basic Git Repository Cloning
You clone a repository with
git clone [url]
For example, if you want to clone the Stanford University Drupal Open Framework Git library called open_framework, you can do so like this:
$ git clone git://github.com/SU-SWS/open_framework.git
That creates a directory named open_framework (at your current local file system location), initializes a .git directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. If you go into the newly created open_framework directory, you’ll see the project files in there, ready to be worked on or used.
Cloning a Repository Into a Specific Local Folder
If you want to clone the repository into a directory named something other than open_framework, you can specify that as the next command-line option:
$ git clone git:github.com/SU-SWS/open_framework.git mynewtheme
That command does the same thing as the previous one, but the target directory is called mynewtheme.
Git has a number of different transfer protocols you can use. The previous example uses the git:// protocol, but you may also see http(s):// or user#server:/path.git, which uses the SSH transfer protocol.
You can use following git command to clone with custom directory name
git clone <git_repo_url> <your_custom_directory_name>
Note: You don't need to create your custom directory because it will create automatically
To clone git repository into a specific folder, you can use -C <path> parameter, e.g.
git -C /httpdocs clone git#github.com:whatever
Although it'll still create a whatever folder on top of it, so to clone the content of the repository into current directory, use the following syntax:
cd /httpdocs
git clone git#github.com:whatever .
Note that cloning into an existing directory is only allowed when the directory is empty.
Since you're cloning into folder that is accessible for public, consider separating your Git repository from your working tree by using --separate-git-dir=<git dir> or exclude .git folder in your web server configuration (e.g. in .htaccess file).
To clone to Present Working Directory:
git clone https://github.com/link.git
To clone to Another Directory:
git clone https://github.com/link.git ./Folder1/Folder2
Hope it Helps :)
If you want to clone into the current folder, you should try this:
git clone https://github.com/example/example.git ./
When you move the files to where you want them, are you also moving the .git directory? Depending on your OS and configuration, this directory may be hidden.
It contains the repo and the supporting files, while the project files that are in your /public directory are only the versions in the currently check-out commit (master branch by default).
Usage
git clone <repository>
Clone the repository located at the <repository> onto the local machine. The original repository can be located on the local filesystem or on a remote machine accessible via HTTP or SSH.
git clone <repo> <directory>
Clone the repository located at <repository> into the folder called <directory> on the local machine.
Source: Setting up a repository
Clone:
git clone git#jittre.unfuddle.com:jittre/name.git
Clone the "specific branch":
git clone -b [branch-name] git#jittre.unfuddle.com:jittre/name.git
Make sure you remove the .git repository if you are trying to check thing out into the current directory.
rm -rf .git then git clone https://github.com/symfony/symfony-sandbox.git
From some reason this syntax is not standing out:
git clone repo-url [folder]
Here folder is an optional path to the local folder (which will be a local repository).
Git clone will also pull code from remote repository into the local repository.
In fact it is true:
git clone repo-url = git init + git remote add origin repo-url + git pull
Here's how I would do it, but I have made an alias to do it for me.
$ cd ~Downloads/git; git clone https:git.foo/poo.git
There is probably a more elegant way of doing this, however I found this to be easiest for myself.
Here's the alias I created to speed things along. I made it for zsh, but it should work just fine for bash or any other shell like fish, xyzsh, fizsh, and so on.
Edit ~/.zshrc, /.bashrc, etc. with your favorite editor (mine is Leafpad, so I would write $ leafpad ~/.zshrc).
My personal preference, however, is to make a zsh plugin to keep track of all my aliases. You can create a personal plugin for oh-my-zsh by running these commands:
$ cd ~/.oh-my-zsh/
$ cd plugins/
$ mkdir your-aliases-folder-name; cd your-aliases-folder-name
# In my case '~/.oh-my-zsh/plugins/ev-aliases/ev-aliases'
$ leafpad your-zsh-aliases.plugin.zsh
# Again, in my case 'ev-aliases.plugin.zsh'
Afterwards, add these lines to your newly created blank alises.plugin file:
# Git aliases
alias gc="cd ~/Downloads/git; git clone "
(From here, replace your name with mine.)
Then, in order to get the aliases to work, they (along with zsh) have to be sourced-in (or whatever it's called). To do so, inside your custom plugin document add this:
## Ev's Aliases
#### Remember to re-source zsh after making any changes with these commands:
#### These commands should also work, assuming ev-aliases have already been sourced before:
allsource="source $ZSH/oh-my-zsh.sh ; source /home/ev/.oh-my-zsh/plugins/ev-aliases/ev-aliases.plugin.zsh; clear"
sourceall="source $ZSH/oh-my-zsh.sh ; source /home/ev/.oh-my-zsh/plugins/ev-aliases/ev-aliases.plugin.zsh"
####
####################################
# git aliases
alias gc="cd ~/Downloads/git; git clone "
# alias gc="git clone "
# alias gc="cd /your/git/folder/or/whatever; git clone "
####################################
Save your oh-my-zsh plugin, and run allsource. If that does not seem to work, simply run source $ZSH/oh-my-zsh.sh; source /home/ev/.oh-my-zsh/plugins/ev-aliases/ev-aliases.plugin.zsh. That will load the plugin source which will allow you to use allsource from now on.
I'm in the process of making a Git repository with all of my aliases. Please feel free to check them out here: Ev's dot-files. Please feel free to fork and improve upon them to suit your needs.
If you are in the directory you want the contents of the git repository dumped to, run:
git clone git#github.com:origin .
The "." at the end specifies the current folder as the checkout folder.
If you are using ssh for git cloning you can use the following command.
git -C path clone git#github.com:path_to_repo.git
eg:
git -C /home/ubuntu/ clone git#github.com:kennethreitz/requests.git would pull the git repository for requests to your /home/ubuntu/ path.
go to the directory where you want to clone the repo.
(don't run git init command inside that directory)
simply run the command,
git clone <git repo url> .
Example: git clone https://github.com/Rashmi-Wijesekara/portfolio.git .
Although all of the answers above are good, I would like to propose a new method instead of using the symbolic link method in public html directory as proposed BEST in the accepted answer. You need to have access to your server virtual host configurations.
It is about configuring virtual host of your web server directly pointing to the repository directory. In Apache you can do it like:
DocumentRoot /var/www/html/website/your-git-repo
Here is an example of a virtual host file:
<VirtualHost *:443>
ServerName example.com
DocumentRoot /path/to/your-git-repo
...
...
...
...
</VirtualHost>
If you use github cli you can use the following command:
gh repo clone <repository> [<directory>] [-- <gitflags>...]
So for example you can run this:
gh repo clone repository-name-on-github my-local-folder
For Windows user
1> Open command prompt.
2> Change the directory to destination folder (Where you want to store your project in local machine.)
3> Now go to project setting online(From where you want to clone)
4> Click on clone, and copy the clone command.
5> Now enter the same on cmd .
It will start cloning saving on the selected folder you given .
Regarding this line from the original post:
"I know how to move the files after I've cloned the repo, but this
seems to break git"
I am able to do that and I don't see any issues so far with my add, commit, push, pull operations.
This approach is stated above, but just not broken down into steps.
Here's the steps that work for me:
clone the repo into any fresh temporary folder
cd into that root folder you just cloned locally
copy the entire contents of the folder, including the /.git directory - into any existing folder you like; (say an eclipse project that you want to merge with your repo)
The existing folder you just copied the files into , is now ready to interact with git.

How can I view files from directories deleted from subversion?

Some directories were removed from a Subversion repository at a given revision. The history still exists for these directories and their files. How do I view a file from such a directory at a revision in the past? I tried using "-r NUMBER" for svn cat and svn ls but it still complained that the file was not found for the latest revision.
If you deleted branch 40, this doesn't work:
$svn annotate svn+ssh://svn/space/svn/supercow/branches/40/pom.xml
svn: '/supercow/branches/40/pom.xml' is not a file in revision 12467
But you can do this:
$svn annotate svn+ssh://svn/space/svn/supercow/branches/40/pom.xml#10000
Could you check out that revision?
I would create a new directory outside of your working directory. Check out the project, or just the parent folder of the file you're interested in.
$ cd tmp
$ svn co -r 123 http://host_name/svn_dir/repository_name/project/trunk svn_test
svn log --verbose
for a given directory
svn log --verbose protocol://url/to/the/folder/which/the/files/were/deleted/under
Find the the revision and file-names that were deleted.
svn up -r 911 deletedFile.ext
To checkout.
well, up is not suggested as per here, use copy instead.

Resources