uploading to github

so i have file and i want to upload it to github and i try to use commands only with cmder to get used to that but after i push it say they are different commit
47 Replies
ABK | Muneer
ABK | MuneerOP3y ago
try to change the commit and now it has errors
ABK | Muneer
ABK | MuneerOP3y ago
13eck
13eck3y ago
Did you try to git pull the upstream changes to your local machine?
ABK | Muneer
ABK | MuneerOP3y ago
i'm relatively new to git and github still learning so i'll just show you what i get lol
ABK | Muneer
ABK | MuneerOP3y ago
ABK | Muneer
ABK | MuneerOP3y ago
the repository is new and empty btw
13eck
13eck3y ago
normally you have to git push origin main (or master, depending on what your main branch is called)
ABK | Muneer
ABK | MuneerOP3y ago
ABK | Muneer
ABK | MuneerOP3y ago
this is what i get rn
13eck
13eck3y ago
git pull origin main ?
ABK | Muneer
ABK | MuneerOP3y ago
13eck
13eck3y ago
Brutal…
ABK | Muneer
ABK | MuneerOP3y ago
did i do something wrong and broke it?
13eck
13eck3y ago
And you're 100% sure the github repo is empty?
ABK | Muneer
ABK | MuneerOP3y ago
ABK | Muneer
ABK | MuneerOP3y ago
was trying to push to master then realized it's new branch
ABK | Muneer
ABK | MuneerOP3y ago
13eck
13eck3y ago
Ok, so not empty. Do you have that readme in your local copy? Oh, you have both main and master?
ABK | Muneer
ABK | MuneerOP3y ago
i don't
ABK | Muneer
ABK | MuneerOP3y ago
ABK | Muneer
ABK | MuneerOP3y ago
i'm trying to send pic
13eck
13eck3y ago
try git pull remote master then. Maybe you're synced to the master branch and not the main branch Yeah, Discord is being slow right now
ABK | Muneer
ABK | MuneerOP3y ago
ABK | Muneer
ABK | MuneerOP3y ago
wait i will just delete the git file and redo it with new repository
13eck
13eck3y ago
Honestly, I'd suggest deleting the github repo and making a new, empty directory Delete the .git…yeah, you got it 😜
ABK | Muneer
ABK | MuneerOP3y ago
i was researching that for like an hour lol
13eck
13eck3y ago
Git is very powerful, but with great power comes great easy of fucking up lol For git, the rule of thumb is to only make changes in one place at a time, either locally or on the remote (github). If you do work on multiple computers then be sure to push all changes from one machine before leaving it so you can pull from the other if you need to. That way everything stays synced.
ABK | Muneer
ABK | MuneerOP3y ago
yah and i know i'll need it to be a dev as well I'VE DONE IT !
13eck
13eck3y ago
It takes a long time to get it right. Heck, I tend to use VS Code's git integration because it's less error prone
ABK | Muneer
ABK | MuneerOP3y ago
turn out if i don't add readme file they give you step by step how to upload is that plugin ? can you send video explaining how to use it
13eck
13eck3y ago
It's part of VS code as far as I know
ABK | Muneer
ABK | MuneerOP3y ago
is there a way to automatically make the branch name to main to not face this issue again?
13eck
13eck3y ago
Is it not main by default? Thought they made that change a long while ago
ABK | Muneer
ABK | MuneerOP3y ago
every time i use git init it makes it master and being newbie get confused with all the commands
13eck
13eck3y ago
One thing you can do is to rename the branch in GitHub before pushing your local code to it But if you've already pushed your code you can do git branch -m master main
ABK | Muneer
ABK | MuneerOP3y ago
it's already main now before i pushed it
13eck
13eck3y ago
-m means "move" so it'll "move" your current branch (master) to the new branch (main). Be sure to git push origin main after the move command
ABK | Muneer
ABK | MuneerOP3y ago
what about the -u
ABK | Muneer
ABK | MuneerOP3y ago
oh got it ! thank you for the help !
13eck
13eck3y ago
Honestly I know just enough git to know what commands I should be using and consult the docs It's also how I do most HTML, CSS, and JS :p 🤫 Don't tell anyone, reading docs is my superpower
ABK | Muneer
ABK | MuneerOP3y ago
i can't do that, i got plugin that read the page for me lol
13eck
13eck3y ago
think sounds rough
vince
vince3y ago
Idk if this would work in the future but you could have maybe done git reset --hard to reset to the last commit I don't think that would have pulled a file you don't have though 🤔 but it's a command I've used a lot of times when git pull origin master refuses to work
ABK | Muneer
ABK | MuneerOP3y ago
will try it next time !
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
ABK | Muneer
ABK | MuneerOP3y ago
Yes after learning more about git and github I start uploading and I'm pretty sure I was doing it with wrong branch so the fix was to do "git branch -m main" to switch the branch to main because it was being uploaded to a branch name master
Want results from more Discord servers?
Add your server