Git push creates my project folder inside another folder, how to avoid it? - github

I have been creating some repositories of my projects since the terminal and everything was good, but recently I tried to push a project to GitHub and but another folders are created.
For example, the path of my project folder is /Desktop/Programming_course/React_Native/robotreact.
So, since the terminal I go to the path of my Project robotreact and I run:
git add .
git commit -m "first commit"
Then, in GitHub, I create my repository and after that I run:
git remote add origin https://github.com/Josesosa0777/robotreact.git
when I push it running: git push -u origin main
In my GitHub are created other folders:
How can I avoid those extra folders?
It seems like if another project is added, I am not sure if the problem is about a SSH key, I dont know how to solve it, any idea?

That means you have initialized your Git repository in / instead of /Desktop/Programming_course/React_Native/robotreact: check for /.git
If that is the case, and you don't have many commits, you can simply:
delete /.git
initialize the repository in the right folder,
add the remote origin
add files, commit and push
That is:
cd /Desktop/Programming_course/React_Native/robotreact
git init .
git remote add origin https://github.com/Josesosa0777/robotreact.git
# check your user.name/user.email
git config user.name
git config user.email
git add .
git commit -m "First import"
git push -u origin main
If your local branch is master:
git push -u origin master:main

Related

Pushing folder into github

I was trying to push the folder on my computer to GitHub. So I created a GitHub repository, and use git bash command line. I didn't push the folder successfully on my first try. Then, I deleted the old GitHub repository and created a new one, and tried using the git bash command line to push code again. However, it shows nothing to commit.
Here is an image to better help understand
According to the image, I understand that you have made a commit but your commit was empty and you did not track any file with git beforehand. You typically want to track the files you want to commit. So in this case you could use git add before committing:
git add .
This should track all files in the current folder after which you could commit and push them:
git commit -m "Some message"
git push
When you create a new repository on git, it shows you how to properly upload data
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/youracc/your.git
git push -u origin main

How to push eclipse workspace projects to git using GIT CMD desktop application?

I would like to synchronize all my eclipse workspace to a github repository. Please tell me the list of commands to do it.
To access Git commands from CMD. You have to set the PATH Environment Variables to Git's bin directory, mine is C:\Program Files\Git\bin.
Then configure your information for all local repo
git config --global user.name "[name]"
git config --global user.email "[email address]"
Create your repository on GitHub. Then go to your project directory(eclipse workspace projects) git init [project-name] and add all files to staging area git add --all or git add * Then commit it with some message git commit -m “Initial Commit” and then git remote add origin <url> then push your files to GitHub git push origin master
See this GIT CHEAT SHEET to know more...
Updated :
Here is the link to download GIT Cheat Sheet PDF.
Take a look !
GIT CHEAT SHEET
If you cloned your Eclipse workspace from a GitHub repository, all you need to do is
git push origin master
If you didn't, you first need to create an empty repository on GitHub. Then copy and paste the URL at the top of the page for your new repo. From the command line type
git remote add origin <paste URL here>
Now you can use the same git push command as above to push your git history to the new GitHub repo.

C9 created workspace before repository

I made the mistake of creating a workspace before a repository on C9.io.
As a result I do not have version control. Naturally, I want to use Git for my project before make any more changes. Everything I have tried has failed. I would rather not have to copy all the code I've made into a new work space with an already set up repository. So if anyone has any suggestions or answers to this problem, via Command line, GUI or anything else that would be wonderful.
cloud9 doesn't do any special magic when cloning from a git repository, and you can add a remote the standard way you would do locally:
git init initialize a git repository in the current folder
git add -a add everything (or what you want)
git commit -m "initial commit" commit
git remote add origin git#github.com:<me>/<repo>.git add your repo
git push origin HEAD:master push HEAD to master branch in the remote you just added

push my project to github

I followed these steps: https://help.github.com/articles/generating-ssh-keys
now, I want to create a folder in my github account, is called: "TODO_LIST", and push my project into this folder.
what I should do? I'm located in the folder I want to add.
should I need to do something like the next following?
$ git init
$ git add .
$ git commit -m 'first import'
$ git remote add origin git#github.com:alonshmiel/TODO_LIST.git
$ git push origin master
p.s, I have two SSH keys in my account because I push from two computers.
This is explained in the Create a Repo help page:
Every time you make a commit with Git, it is stored in a repository (a.k.a. "repo"). To put your project up on GitHub, you'll need to have a GitHub repository for it to live in.
[...]
Click New Repository.
Fill out the information on this page. When you're done, click "Create Repository."
[...]
git init
# Sets up the necessary Git files
git add README
# Stages your README file, adding it to the list of files to be committed
git commit -m 'first commit'
# Commits your files, adding the message "first commit"
[...]
git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repo
git push origin master
# Sends your commits in the "master" branch to GitHub

github uploading project issue

I created a github new repository first in github webpage and then I opened Git Bash to upload folders to this repository. I first used $cd f: and $ git clone git#github.com:username/project name.git to create a folder(with a initial .git folder and a README file in it) in f disk. Then, I used $cd f:\project name to switch to the current folder. After that, I copied all my project folders to my project name folder in f disk. Finally, I used the following four lines to upload all my project folders to github:
$git add .
$git remote rm origin
$git remote add origin git#github.com:username/project name.git
$git push -u origin master
After I entered the passphrase, Git Bash just showed everything up-to-date. But I refreshed my github repository page, there is nothing but the initial README file. Could someone tell me what the matter is?
You didn't commit after your git add.
git commit -m "first commit"
That is why git considered there was nothing to push: you HEAD was still the same than your remote origin cloned repo.
See Git Basics:
Your git add updating the staging area (index), but only a git commit will update your git directory.