Not able to push to new repository on Github - reactjs

I created a repository on GitHub and pushed successfully to it. However, I had trouble pushing my 'backend' folder. Eventually I did get but it still didn't look the same as the code I had on VS Code. For sake of organization I decided to delete that repository and create a new one. This time the folders I was missing previously (two parents folders, one for frontend, one for backend) managed to upload but all the files inside them (that were pushed to previously deleted repository) didn't get pushed to my new repository.
Git add -A and git add . don't change anything.
git push, returns 'Everything up-to-date'.
git remote is connected just fine.
Please help stack overflow community, you're my only hope. current repository if it helps: https://github.com/mazorSharp/mern-e-commerce

Your backend and frontend entries in the listed repository are both gitlinks: the main operating part of a submodule. You get a submodule because you told Git to store a Git repository inside a Git repository. Git literally cannot store a Git repository inside a Git repository, so it won't. Instead, Git adds what I like to call a "half-assed submodule": the part that says use this particular commit: ______ (insert hash ID here) from the associated Git repository.
The reason this is "half-assed" is that the "associated" Git repository isn't associated. To be associated, Git needs a separate piece of information. To put that information into Git—which you need only do once per submodule—you would normally use git submodule add. This will create or update the .gitmodules file, in which the association information is stored. Once you have both pieces of information, the gitlink becomes useful ("fully assed"?).
Once you have a proper submodule, cloning the superproject gets you a repository that refers to some other repository. That other repository is not yet cloned so you must run git submodule update --init or equivalent. This tells your Git software to poke around in the submodule instructions (in the .gitmodules file), figure out whether you have the submodules properly cloned yet, and if not, clone them. Then, once the submodules are cloned, git submodule update (with or without --init) will look at each gitlink, which says which commit hash ID to use out of each submodule, and will enter each submodule, one at a time, and check out the correct hash ID, resulting in a detached-HEAD setup in the submodule. This is how submodules are intended to be used. (They are annoying to use, and rather brittle, so some people call them sob-modules.)
If you don't want submodules—whether you do or don't want them is your decision, that no one else can make for you—you'll have to remove the repository-ness of the subdirectories in question. To do that, you will need to move or remove the .git file-or-directory that is found in backend/ and frontend/ in your working tree. Note that if .git is a folder full of files, it contains the entire repository, i.e., all of the history; removing it removes this history, leaving you with just one set of checked-out files. If that's not what you want to do, don't remove the .git, just move it completely out of this part of your file system.

Probably you need to delete .git folder by using the following command and start with git init and point to the new repository. Note: This will remove your all previous commits.
rm -rf .git
Or else you can change the upstream URL by using this command,
git remote set-url origin <<new git url>>

Related

How to push entire React folder to github?

I am working on a project that uses both React and Springboot apps, so I have individual folders for each of those and am trying to get them both into my github repo. I was easily able to drag and drop the springboot folder, but my react one does not upload at all when I drag it into the upload box. Is there an easy terminal command in vs code (the editor I'm using) to add the entire folder?
Since you want to add your 2 different projects in 1 repository, you can firstly put both of your project folder inside 1 main folder, example:
MyFolder:
- MyReactProject
- MySpringbootProject
here MyFolder is your main folder, which has both of your projects, react and springboot.
then finally make a file inside MyFolder with name .gitignore, and put this line inside that file:
**/node_modules
what this file will do, is when you will push your code to github, it will ignore all the files and folders which are listed inside .gitignore file.
You Don't Need node_modules folder
when uploading your code somewhere online, you don't need to upload the node_modules folder, because this folder contains all the dependencies your project need, but when uploading your code online people can download those dependencies by calling the command npm install which will read all the modules needed from your package.json file, and download it on your machine.
To upload your code online you first have to authorize yourself on your local git program, to authorize yourself for github you can read this Article.
After authorizing yourself, firstly make a new empty github repository, by going to github or just by clicking this Link, after making a github repository open Terminal/Command Prompt in your Folder where both of your projects were, in this context my both projects were in MyFolder.
After opening Terminal/Command Prompt enter this commands:
git init
git branch -M main
git add .
git commit "Added all the files"
After running these commands, finally run these 2 final commands:
git remote add origin https://github.com/username/repository-name.git
here, replace username with your github username, and replace repository-name with the name of your repository you specified while make a new repository.
and finally run this command
git push -u origin main
and your code should be pushed on github.
If you don't want to use git commands you can also use, Github Desktop, but it is recommended you first learn basics of git and then use github desktop

how to recover a wampserver root folder from git

I was working on a project that i kept in wampserver root folder. I used a local git repository to save every step of the work. at some point I forgot that the files were inside wampserver and I deleted wampserver to install it again when it was stuck. the folder is not kept in recycle bin too. is there a way I can recover my whole project folder from the last git commit?
It depends if that local Git repository was pushed anywhere (GitHub, GitLab, BitBucket, ...) or not.
Because if that local repository was not pushed or cloned, then it is a simple local set of files, deleted when the wampserver was deleted.
In which case, only some file/data recovery software would be your only approach.

Git didn't add x64\SQLite.Interop.dll

I installed SQLite into my WPF project via Nuget. Then added the entire project to a remote repo. Then I cloned the project on another machine, and had a broken build.
x64\SQLite.Interop.dll was missing.
I'm puzzled why Git didn't include one file from my project. I checked the repo on BitBucket and confirmed it is not there. Git status reports nothing to commit, working directory clean
It added the x86 version, but not the x64 version, I can't imagine why.
(project)\x64\SQLite.Interop.dll Git ignored this file!
(project)\x86\SQLite.Interop.dll
You might want to check the .gitignore file at the root of the repo. If it contains for example x64, it would ignore this file.
There would be two main possibilities then:
edit this file to fit your need
or force this file to be added; ie: git add -f x64/SQLite.Interop.dll
However, committing binary files is often frowned upon. It's true in particular if you want to keep up to date with the latest package, hence if you plan to commit new versions of the dlls on a regular basis.
You might rather want to consider Nuget package restore feature. Basically the idea is that you commit a config file, and the client will automatically download the corresponding packages.

Pull down a file from a remote repo during a clone of your own

I've had a look at one or two similar questions on Stack Overflow, but they don't address what I am looking for exactly, unless I've missed it somewhere.
What I have is my own repo that contains custom boilerplate code. In my repo I'd like to include files from various other remote repo's (not my own). Thus when I'm ready to work on a new project, I can clone my repo, get my boilerplate code, as well as the files from the various other repo's I usually go to manually and download from. This way preferably the up to date versions are pulled as opposed to just copying these files into my own repo and having to update them every time there is a revision.
Is this possible to do simply using Git/GitHub?
Submodule is the way to include other repos.
And you now can define a submodule to follow a branch (git 1.8.2+), which means this will bring you the latest commits of said branch.
git submodule update --remote
I do that in my compileEverything GitHub repo, where I include the latest from Semantic-UI master branch.
That is because my .gitmodules looks like:
[submodule "Semantic-UI"]
path = Semantic-UI
url = https://github.com/jlukic/Semantic-UI
branch = master
I'm not particularly looking to include an entire repo/branch but just a select few files within one.
Example: Normalize.css Still possible to do?
No. It is best to:
include the full repo through a submodule (since the submodule pointer itself hardly takes any place in your repo)
keep in the parent repo symlinks to the files you need from that submodule.
That way, you see:
the files you want (symlinked to the same files from the subrepo)
the subrepo reference, that you can update at will.

Why isn't GIT tracking my cakephp migrations Plugin?

I am using GIT to deploy my cakephp applications, a few days ago I started using the migrations plugin (by cakeDC) in my app to simplify database versions and changes.
After installing the Migrations Plugin on my local development machine, I committed the changes and pushed it to my production server, and tried to run the migrations plugin from there.
After looking at the server for quite some time I realized it had not grabbed all of the migrations plugin, however the following were changed:
app/Config/bootstrap.php had the following line appended
CakePlugin::load('Migrations');
The Plugin folder now had a Migrations folder, but it was empty.
I resolved this by uploading the plugin via FTP. I ran a git status on it and it shows the working directory clean...
Why isnt GIT tracking my Migrations plugin folder contents?
The Plugin folder is not being tracked because GIT thought it was a submodule.
I ran into this issue because I used GIT to clone this Plugin into the plugin directory. and git didnt add it since it was a repository in itself. When GIT didnt add it to my tracked files I did it manually: git add app/Plugin/Migrations/
this created a gitlink and essentially acted like a submodule, as seen in this thread:
Git - how to track untracked content?
Since at the time I didnt want to use the plugin as a submodule, I corrected this issue with the following commands:
git rm --cached app/Plugin/Migrations
with a git status I could see that GIT was now recognizing my Plugin
I then could proceed with a git add . and git commit -m "finally adding the plugin"
I hope this helps someone in the future.
Thanks!

Resources