I'll summarize what happened to my computer.
To upload my local folder "freshman" to github repository named "Hanyang", I typed the commands below;
git init
git add freshman
git commit -m "blahblah"
git remote add origin https://github.com/myUsername/Hanyang.git
git push -u origin master
git push origin master
But I realized that the folder is well uploaded but inadvertently at the ' master ' branch, while the default branch was ' main '.
So I manually deleted ' master ' branch in github, got back to git bash then tried git add freshman
again.
Did I have to do something to change the target branch ( master > main ) before merely trying
git add freshman
again?
Anyway unlike the first typing of the command, however, git bash says "nothing is added" even I checked it via git status
- besides it says "my branch is up to date with 'origin/master' " which I already deleted as the image .
In this situation, what should I do to upload my ''freshman'' folder to the main branch of the repository in github such that I can upload other folders (sophomore, etc.) after this?
run
git branch
to see what branch you are onto switch to main if not on main run
git checkout main
if branch
main
doesn't exist locally you will need to rungit branch main
before checking it outThen you can add your file, set the remote for the
main
branch, and push toorigin main
git branch -M main
for more information, look under Branching & Merging
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.