Pushing folder into github - 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

Related

Git Push "everything up to date" but file on github not change

after i learn to commit a file to github. now i have try to update file on github
by run syntax
git push -u origin main
and output message
Everything up-to-date
Branch 'main' set up to track remote branch 'main' from 'origin'.
when i check again on github the file that i was push no change at all
here my local file
please help me, im new to github
Have you committed first? With git, you need to commit your changes first, which is like saving each version locally. Then, when you push, you are publishing all of your versions to the remote (github).
Try the following:
git status
if it tells you about untracked files, use:
git add <filepath>
then:
git commit -m "<some commit message>"
This will save your changes as a commit locally, and you can now push this commit to github with the push command you used earlier.

Files not appearing on github

I am new to web development and have just created my first project. I created a new repository on github and then did the following on git bash:
Moved to the working directory for my project
Initialized the git repository using git init
Added my files using git add .
Committed the files using git commit -m 'my message'
Added the github URL under code. on github by using git remote add origin 'my_url_name'
Pushed the code to github using git push -u origin master (also entered my passphrase correctly as I am using SSH)
Git Bash confirmed the upload and then nothing appeared on my repository on github
Note. I did get a message at the top of the repository saying "master had recent pushes x minutes ago: with a button that says "Compare & pull request" though the page just shows a message "There isn't anything to compare."
Am I missing a step?
The branch selected in your git is master. But in GitHub is main. To display your codes in GitHub, you need to change the Git branch to main.
First delete previous repository in Github and create a new , then act according to the following codes in the git :
git branch main
git checkout main
git merge master
git branch -M main
git remote set-url origin https://github.com/masoud8911/example.git
git push -u origin main
It could be that your local branch name is main not master. You can check this locally with:
git branch.
try instead:
git push -u origin main
Make sure you are selecting the correct branch on github. At the top of the repository, on the same line as "Go to file" "Add file" and "Code" on the far left is a button to select the branch. Make sure the branch is the same as the branch used as origin when the push was declared on Git Bash.

How to upload all folder to github?

I have created a repository on github, and run the command line git push -u origin master. I just find a folder over there, but I have a lot of file in my folder, but it only uploaded a folder that has no files in it.
How do I upload a folder with lots of files successfully?
I just tried the command git add . and git push -u origin master
It's not working.
Please me teach me what step I missed. Thanks in advance.
You need to add all of the files in the folder. If you actually want to add all of it (not just some), an easy way to do that would be git add -a or git add ReduxSimpleStarter/*.
Then you need to commit them. git commit.
Then push.
I'm guessing, by your description (sorry, it's a bit hard to read. So correct me if I am missing some details to your problem) you're forgetting to commit the changes.
To do this you need to git commit -m "A commit message". It would look something like this all together
git add .
git commit -m "Added a new button"
git push -u origin master
commit just tells git to save the changes you made to it's history. add just tells git that you want those files (in their current state) to be saved next time you commit.
Hopefully that solves your problem.
It looks like you are not committing your changes before pushing.
When you do this:
git add .
your files are adding to the staging area. But you also need to commit them. You can do this by typing this into you command line after doing the 'git add .' command:
git commit -m "your commit message here"
Then you should be able to type 'git push -u origin master' and your files should upload.

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

How do I commit a new project version on GitHub?

I'm new to GitHub and its terms confuse me a little. I made a commit. Now I want to change the project to a new refactored version.
Do I need to delete files from the existing repo before commiting new version (if the structure was changed and some of the files are not needed anymore)?
Do I need to push or to commit? Or do I need to do something else?
Making a commit updates the repo on your local machine. Doing a push will replicate your repo changes on a remote.
You can commit as many times as you want locally. Once you are happy with the state of your repo, you can update the repo on Github with the following command:
git push origin master
If you want to delete a file from the repo, you can do this:
# remove the file
git rm path/to/my_file
# commit the remove to your local repo
git commit -m "removing my_file"
# update the remote (Github) repo with the removed file
git push origin master
If the repo doesn't exist on Github yet, go ahead and create a repo there. They will give you step-by-step instructions on how to make your first commit. It will likely look something like this:
# go to project files
cd path/to/project
# initialize git repo
git init
# stage all project files in current directory to be committed
git add .
# make first commit
git commit -m "first commit"
# add the Github remote
git remote add origin <YOUR GITHUB URL>
# send repo to git
git push origin master
a commit to github is in two steps:
->first use command commit to save the changes localy
->then use push commande to save the changes on github