GitHub shows a submodule instead of a subfolder - node.js

Git unconsciously created submodule from my subfolder where there was .git lately. I deleted .git and there's no git files like .gitignore but still can't add files to this subfolder. It looks like this
And inside io-invoices (submodule) I've got
I've checked hidden files.

You probably need to remove that directory from the Git tree and re-add it later. Backup everything before!
git rm --cached ./io-invoices
git add ./io-invoices

Related

How to connect two separate folders into the same GitHub repository?

I have already made a GitHub repository with a folder1, but I have a ../etc/etc/folder2 that I would like to add into the same repository because they both are a part of the same project.
As you can see these two folders are not super close to each other, but they are in the same linux file system. How can I add folder2 to my existing GitHub repository that contains folder1?
What I ended up doing was creating the repository in the root directory.
I created a .gitignore file to ignore all files except the two folders that I wanted in the repository.
## Ignore everything...
*
## Except...
folder1
folder1/*
path/to/folder2
path/to/folder2/*
You would need to, locally on your Linux machine, move or copy the folder2 in your local cloned repository, add and commit.
Then you can push, in order to see folder2 in your remote GitHub repository.
The alternative is:
make a Git repository in ../etc/etc/folder2, push it to a separate GitHub repo folder2
reference the remote GitHub repository folder2 as a submodule in your first local cloned repository
That is:
cd /path/to/folder1
git submodule add -b main -- https://github.com/<me>/folder2
That way, you have the repo folder2 referenced by your main repository.
If you change anything in folder2 (original path), add, commit and push.
Then, from the first local cloned repository, git submodule update --remote is enough to update the folder2 submodule content.

How to ignore files folder after committed to git for drupal 8 server?

I am in a situation where files have been committed to git. While doing git status -s files folder changes are showing. I have tried updating gitignore but it’s not working.
I cannot delete the files folder and then update gitignore file with sites/*/files because I have a running application.
add <File/Dir> in .gitignore
2)git rm -r --cached <File/Dir>
The command will remove it from git repository only and as it is part of gitignore, the removed directory or file will not be pushed to remote repo. Any further changes to dir will remain untracked.

Git tracking to wrong local directory

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.

Moving git repo from public_html/stage folder to root public_html/

On my linux server I have a website running in public_html/stage which i cloned from guthub to /stage folder.
Now after the development is over i want to move this folder to root i.e public_html folder, making sure that its sync with my repo.
I tried to cp all /stage files to the root directory but the main folder /app was not copied.
Pls guide me how can I move this staging to production.
Also please let me know what is the standard way of doing this?
They're just files, you can copy them.
cd /path/to/public_html
cp -r stage/* .
Make sure not to copy your Git repository, the .git directory. If you did, that would turn public_html/ into a Git repository.
If you do want to move the whole repository into public_html, again it's just files. Everything git needs is in stage/.git/.
I got the solution to my problem, but not sure if what I did is a standard way. But anyhow it resolved my problem. So here is what i did...
I initialized an empty repo in public_html folder and then added remote to my github repo and finally fetch all code from the repo.
$ git init
$ git remote add origin https://github.com/user/repo.git
$ git fetch --all
$ git reset --hard origin/master
So now my project is working fine at the root of the website and is in sync with the repo. So everytime I do some local changes to my repo I only need to pull them from repo
$ git pull origin master
And thats all!

Git ignore and changing the history (on Windows)

I've already read several posts about this here (like Git ignore & changing the past, How to remove files that are listed in the .gitignore but still on the repository?, and Applying .gitignore to committed files), but they have several problems:
Commands that only work on Linux.
Incomplete commands (like the first post I've linked to).
Only for one file.
I have pretty much no experience with Git so I was hoping for some help here.
What I'm basically trying to do is rescue one of my projects history. It's currently Hg and I converted it to Git with Hg-Git (all very easy) and it includes the history (great!). However, I also added a .gitignore file and added several new files & folders that I want completely gone from the history (like the bin and obj folders, but also files from ReSharper). So I'm looking for a way to apply the .gitignore file to all of my history. The commands should work on Windows as I have no intention of installing Linux for this.
No need to add the .gitignore in the history (there is no added value to do it), just add it for your future commits.
For the remove of files and directories in your history, use bfg-repo-cleaner which is fast, easy and works very well on Windows (done in scala).
It will do the job for you!
This is working for me:
Install hg-git.
cd HgFolder
hg bookmark -r default master
mkdir ../GitFolder
cd ../GitFolder
git init --bare
cd ../HgFolder
hg push ../GitFolder
Move all files from GitFolder to a '.git' folder (in this GitFolder) and set this folder to hidden (not the subfolders and files).
cd ../GitFolder
git init
git remote add origin https://url.git
Copy all current content (including .gitignore) to GitFolder.
git add .
git commit -m "Added existing content and .gitignore".
git filter-branch --index-filter "git rm --cache d -r --ignore-unmatch 'LINES' 'FROM' 'GITIGNORE'" --prune-empty --tag-name-filter cat -- --all
git rm -r --cached .
git add .
git gc --prune=now --aggressive
git push origin master --force
There is probably an easier way to do this and it might not be perfect but this had the result I wanted.

Resources