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.
Related
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
I accidentally pushed a file to my Github repository, and I am trying to understand where it is.
I have read many posts in here, but none of them had the solution, so I wanted to ask.
My steps were:
git status
git add normal_file.txt
git add sensitive_content_file.txt
git rm --cached sensitive_content_file.txt
#It was the time that I realized I have added a wrong file and need to remove it.
git commit -m "new changes"
git push
I saw that it pushed the "normal_file.txt " into my repository however I have not seen the "sensitive_content_file.txt" in my repository, so I assume it is not being pushed? So that all is okay?
I have tried to clean cache but now my repository complains as:
" Your branch and 'origin/master' have diverged, and have 1 and 1 different commit each, respectively."
However, I did not do any changes to itself.
How can I clear every connection to this file with I tried to remove its caches?
git rm --cached sensitive_content_file.txt before the commit was enough to not pushing it to GitHub.
But now, it would be best to add that file to your .gitignore, in order to be sure to not add it again by mistake:
echo sensitive_content_file.txt>>.gitignore
git add .gitignore
git commit -m "Ingore sensitive_content_file.txt"
git push
If you did any rebase/commit --amend, that would change the local history compared to what was pushed.
If you have not done any local modification, a git reset --hard origin/master would reset master, then you can modify the .gitignore and push.
I would like to push a project on github. However I cannot push all the projects. It still some subfolders that are not uploaded. What can I do ?
Only files that are tracked and committed will be 'uploaded' when you push to the remote server.
Check if the folders are added. You can do a git status, and it will list them as untracked if they haven't been added.
Add them. git add [file/folder name]
Commit them. git commit -a -m "Adds [some file]"
Push to your remote. git push -u origin master
Make sure those folders are not ignored. Pick one file in them and type:
git check-ignore -v path/to/ignored/folder/afile
That will print any .gitignore file/rule which might apply and explain why said folder was not added/committed when you dod a git add ./git commit.
I don't know how, but I somehow turned a file into a submodule. So now I can't view it in Github. How do I undo this, to make the file clickable again?
(I've read through answers to similar question in stackoverflow, and they don't make much sense to me...I'm pretty new to git)
You either need to revert to a past commit where that file was not a submodule:
git log path/to/file
git checkout <past_commit> -- path/to/file
Or you could delete that entry and restore the file, adding it and committing it again.
git rm -- path/to/file
# copy the file
git add -- path/to/file
git commit -m "restore file"
Okay. So I've got forked repository from my college teacher. I need to change main.cpp, then commit and push changes. I've done something like this:
git config --global user.name "username" and same thing with e-mail
ssh-keygen -t rsa -b 4096 -C "email"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
And then I did: git clone adress (SSH). Files were copied correctly. I've edited my main.cpp, saved changes, and then did: git commit -m "Solution" and git push. This is my terminal:
And here I edit main.cpp. Then:
What am I doing wrong?
You first need to stage files for commit. Learn more about staging with git in this tutorial.
The git add command adds a change in the working directory to the
staging area. It tells Git that you want to include updates to a
particular file in the next commit. However, git add doesn't really
affect the repository in any significant way—changes are not actually
recorded until you run git commit.
In your case, just before the commit do:
git add main.cpp
after your changes to source code, you need to do
git add .
git commit -m "Solution"
to upload you commits to remote
git push origin yourbranch