How to Push Code to a GitHub Repository

Поділитися
Вставка
  • Опубліковано 30 січ 2025

КОМЕНТАРІ • 108

  • @cameronmcnz
    @cameronmcnz  Рік тому +1

    There a full tutorial on how to push an existing project to a new GitHub repo over on TheServerSide:
    www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-push-an-existing-project-to-GitHub

  • @annak5579
    @annak5579 29 днів тому +1

    I'm just a beginner in coding and naturally I face a ton of difficulties, like this one I had with creating a repo based on another repo. ngl I spent hours trying to figure out why it wasn't working and what I was doing wrong, until I finally found this video. Huge thanks mate ♥ I searched the whole internet and no one explained it better than you

    • @cameronmcnz
      @cameronmcnz  28 днів тому

      If it makes you feel any better, I spent two days trying to figure it out. Hoping I could save others the frustration was one of the reasons I made the video. Thanks for watching and commenting!

  • @Frankie_Freedom
    @Frankie_Freedom Рік тому +6

    This actually clears it up, I don't use github much, but what I always had a hard time understanding was switching repos. Now I see that you do the setup on each separate folder that you are attaching to each different repo

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      Yup! That's exactly how it works!

  • @ivanphone4917
    @ivanphone4917 Рік тому +2

    I like the easy approach to adding a project to GitHub. Much easier to push existing code to GitHub that way.

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      Trying to make adding new projects to GitHub as easy as I can!

  • @dominicabah5431
    @dominicabah5431 Рік тому +1

    Thank you so much! I got drifted here for something else and this helped clear that as well.

    • @cameronmcnz
      @cameronmcnz  Рік тому

      Happy that you drifted in this direction! And super glad I could help!

  • @nickl3135
    @nickl3135 10 місяців тому +1

    You the man, thanks for the clear instructions ! I swear Github can be quite the pain at times.

    • @cameronmcnz
      @cameronmcnz  10 місяців тому

      Glad I could help!
      I actually uploaded a newer video to show some alternatives to the force push. Some clone shenanigans and some git rebase options. Plus, I'm improved my mic and camera.
      I put together a 2 hour Git and GitHub video as well.
      Honestly, once you start to understand the philosophy behind Git and GitHub, it all falls into place and becomes a lot easier!
      www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-push-an-existing-project-to-GitHub

    • @nickl3135
      @nickl3135 10 місяців тому

      @@cameronmcnz Great, I will definitely be checking those videos out, need to gain some further understanding !

  • @DJ_Melech
    @DJ_Melech Рік тому +1

    Thanks for this. The "proper" way you did first time solved my issue.

    • @cameronmcnz
      @cameronmcnz  Рік тому

      Happy to have helped! Thanks for watching and commenting.

  • @RandallNewman
    @RandallNewman Рік тому +2

    Thank you! The -f approach is what I needed actually!!

    • @cameronmcnz
      @cameronmcnz  Рік тому +2

      Sounds rather unchristian when you put it that way, but I'm glad it helped!
      Just know that forcing a commit onto a repo shared with others might mess up their repos, so others might have to do a fresh clone the next time they fetch from the server.
      Of course, if this is just the first setup operation, it shouldn't matter. People won't be pulling from the repo until the project is set up in git.

    • @RandallNewman
      @RandallNewman Рік тому

      This was the first commit on a repo I created on bitbucket and had the .gitgnore checked. When I did that I was like -fooey! Then I found your video and all is well. Thanks again.

  • @kabwere
    @kabwere 11 місяців тому +1

    This has helped me with my first repo. Thank you!

    • @cameronmcnz
      @cameronmcnz  11 місяців тому

      Glad I could help! Git and GitHub gets a lot easier once you get the initial connectivity all worked out!

  • @baohuariley5740
    @baohuariley5740 3 місяці тому +1

    Thank you so much! I like the easy way to push code. I followed your instructions and ... job done!

  • @asimdhali6447
    @asimdhali6447 Рік тому +2

    At last I find the effective video, thanks this tutorial helps me lot

  • @Last_Voyager
    @Last_Voyager 10 місяців тому +1

    Thanks man. You helped a lot!

    • @cameronmcnz
      @cameronmcnz  10 місяців тому

      Glad I could help. Git and GitHub gets a lot easier when these connectivity issues are out of the way. Happy Git!

  • @kirklimbu
    @kirklimbu 10 місяців тому +1

    Thanks for simplifying. It helped.

    • @cameronmcnz
      @cameronmcnz  10 місяців тому

      I was worried I overcomplicated it! Once you get Git and GitHub integrated, the whole Git experience becomes a whole lot easier. Thanks for watching and subscribing.

  • @reamageorge9648
    @reamageorge9648 9 місяців тому

    Thank you so much, got what I needed in the first 5 mins.

  • @_sorridente_
    @_sorridente_ Рік тому +2

    A friend shared this video with me; I like your teaching style and have subscribed. Is there a reason you haven't updated your default branch from master to main?

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      The latest Git install still defaults to master, and I try to keep my tutorials as standard as possible, so that is often a reason.
      I'm surprised I didn't point it out in this video, but in almost all videos I do I mention the switch to main and that such a naming strategy is now preferred. It actually causes a lot of problems when a Jenkins server defaults to looking for master (which the latest version still does), while the latest GitHub repo only has main.
      It's a topic I've written about a lot over on TheServerSide. Here's an article from 2019:
      www.theserverside.com/opinion/Master-slave-terminology-alternatives-you-can-use-right-now
      Also one specifically about Git and GitHub:
      www.theserverside.com/feature/Why-GitHub-renamed-its-master-branch-to-main
      Sadly, the transition has been slow.

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      Oh, and send my appreciation to your friend. And to you for subscribing!

  • @MirandaEtonde-qq3cn
    @MirandaEtonde-qq3cn 4 місяці тому +2

    You just saved me🤭 take it from me am not exagerating i mean it's been 3 days am trying to push my code

    • @cameronmcnz
      @cameronmcnz  4 місяці тому

      Did you employ the 'cheat method?'
      There are a lot of variables, like if it's a new repo, an existing repo and stuff like that. I tried to cover as much as I could while keeping things fairly sensible.
      Super happy if I helped. Trust me, git gets a lot easier from here on in!

  • @Victor_with_a_C
    @Victor_with_a_C 7 місяців тому +1

    the way he said "i don't care" 😂😂😂😂😂

    • @cameronmcnz
      @cameronmcnz  7 місяців тому

      It's all a lie. I actually do care.
      Thanks for watching!

  • @TerryGoh-zg6ru
    @TerryGoh-zg6ru 6 місяців тому

    Thank you for the easy way. Any idea how to easily push new or modified codes from our existing cloned repository in our computer to the github repository? Thank you.

  • @Stylemoongirl
    @Stylemoongirl Рік тому +2

    After paste my url in comman, I didn't get any new folder called .git in my repos folder! there just one file read me! why???

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      It's a hidden file, so to see the .git folder you'd need to change your folder settings to show hidden files.
      Windows? I think from Git BASH you can do an ls -a command and it shows hidden folders too!
      Also, just run the git status command in that folder. If the command works, you're good!

    • @Stylemoongirl
      @Stylemoongirl Рік тому

      @@cameronmcnz this really works Thaaaaaaaaaaaaaaaaaaaank youuuuuuuuuu I spent 2 weeks to solve this problem with github! this really works THANKSSSSSSSSSSSS

  • @daydreamers8254
    @daydreamers8254 11 місяців тому +1

    my VSC terminal is demanding i authenticate my github on a website which is asking for INSANE amounts of money per month...i did everything right in the gitbash terminal for my project
    the repoository exists
    but the project will NOT upload unless i shell out money.
    it's been free and i've been using it for free for YEARS
    so WTF is going on?!?!

    • @cameronmcnz
      @cameronmcnz  11 місяців тому

      Is it GitHub that is asking for money? That doesn't seem right to me.

    • @daydreamers8254
      @daydreamers8254 11 місяців тому

      @@cameronmcnzplease help me (also why are my comments gone / not showing up)
      i just typed a long important comment bout how i ot it work finally only for it to all vanish on commenting.
      now i forgot. and it won't work again, and there's no more money issues popping up.
      it just simply won't work.
      i use VSC so i have Bash terminal In the project directory ALREADY.
      then i do the following:
      git init
      git add .
      git commit -m "message here"
      git remote add origin (paste in repo URL)
      git push -u origin master
      and it doesn't go to the repo. even if i get the error you got, and do the thing you did, still nothing happens. the ONLY thing that DOES happen is a git folder is made, a repo is made, and a readme.md is made.
      but the project never makes it.
      i wish to the good lawd i wrote it down or put it in a notepad...
      anything to remember the easiest part of coding.
      i can tell you build orders from all 4 races in wc3 roc that came out in 2001 or 02, same witht its expansion, in all match ups even map based, naming hotkeys, naming hero ability hotkeys, it's SAD i can remember something from 20 years ago so well but i can't remember something from 15 hours ago that worked...
      even with videos and github showing you "how to do it" - it still does NOT work.... idk what to do bro, unless you can get on discord (make a throw away or join my 0 budget one...) i honestly give up for trying to upload to github tonight.
      unless you reply, PLEASE reply, i D O apologize for my spam comments and SUPEr LONG messages... but i can not help it...

  • @bautipiaggio
    @bautipiaggio Рік тому +2

    Very useful my man, thank you very much

    • @cameronmcnz
      @cameronmcnz  Рік тому

      Things get a lot easier with Git and GitHub once you get stuff like this out of the way, I promise!

  • @smartoluwamuyiwabeyioku8766
    @smartoluwamuyiwabeyioku8766 8 місяців тому

    You can use the command "git switch -c branch_name" to create another branch and you can go ahead and run the "git push -u origin branch_name", and it works fine

  • @prtk2verma
    @prtk2verma 7 місяців тому

    ❤❤bro handled it sarcastically

  • @sunnykwan5630
    @sunnykwan5630 Рік тому +1

    How do you make version control on the approach of copying folder. I guess what you modify in the original folder will not affect the copied folder. So, whenever u change something in your project, that will actually not recorded.

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      Yeah, you'd just start doing development in the folder where you copied everything.
      Or, you can just copy the hidden .git folder that gets created in the new folder back into the original one. That's where Git keeps all ofits files.

    • @sunnykwan5630
      @sunnykwan5630 Рік тому +1

      @@cameronmcnz ok thank you so much. Already done it.

    • @cameronmcnz
      @cameronmcnz  Рік тому

      How did it work? @@sunnykwan5630

    • @sunnykwan5630
      @sunnykwan5630 Рік тому +1

      @@cameronmcnz I just use your way by copying the folder

    • @cameronmcnz
      @cameronmcnz  Рік тому

      I hope I didn't overcomplicate things. My hope was to make it a bit easier than editing remote references in a config file.
      Have fun with Git!
      @@sunnykwan5630

  • @SrihariVemana-on6nk
    @SrihariVemana-on6nk Рік тому +1

    Thank you so much, this was very helpful!

    • @cameronmcnz
      @cameronmcnz  Рік тому

      Did you use the cheat method or the proper method?

  • @ascertain3987
    @ascertain3987 11 місяців тому +1

    Very helpful tutorial.

    • @cameronmcnz
      @cameronmcnz  11 місяців тому +1

      Thanks for the kind words! Once you get your local Git project pushed to GitHub, things get a lot easier.

  • @arhampersonal
    @arhampersonal Рік тому +2

    Thank you soo much sir 🙂❤️

  • @sen7826
    @sen7826 Рік тому +1

    But if we do it the easy way, we seem to have to lose any git history in our local folder. I would like to do it the easy way but I don't want to lose the history either

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      For this video, I'm never sure if people have a new, fresh project without git, or an existing git repo with its own history merging into another one with a history.
      I kinda assumed the local project had no git. You just want to get it to GitHub.
      In your situation, a rebase may be better than a forced merge!

    • @sen7826
      @sen7826 Рік тому

      @@cameronmcnz thank you

  • @peacemunii910
    @peacemunii910 9 місяців тому +1

    This was great thank you!

  • @alexdominguess
    @alexdominguess 6 місяців тому +1

    Using the git UI is the best and easier option

    • @cameronmcnz
      @cameronmcnz  6 місяців тому

      Which one? The Git GUI that comes with the install? I was thinking of doing a long-form video on that, actually.

  • @donaldleclerc8021
    @donaldleclerc8021 Рік тому +1

    What about a git pull --rebase then git push instead of rewriting the remote history with - f ?

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      Actually, I was going to add that as a third option but everyone always gets intimidated by a rebase.
      I might add that to the actual article I wrote on theserverside. It's a smart suggestion.
      www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-push-an-existing-project-to-GitHub

    • @cameronmcnz
      @cameronmcnz  Рік тому

      On your suggestion I added the rebase option to this video here on git remote add origin.
      ua-cam.com/video/jq1ROBgmEzw/v-deo.html

  • @Deepa0811
    @Deepa0811 Місяць тому +1

    I always create a project with Readme and copy files. This GitHub force nonsense irritates me.

  • @sharzoe
    @sharzoe 3 місяці тому +1

    Couldn't you simply create the repository in the folder where your code already exists instead of having to copy and paste?

    • @cameronmcnz
      @cameronmcnz  3 місяці тому +1

      Yes. But there are a number of things that would complicate the process that would throw off new Git users, and I want to save new users from that frustration. For example, if the project already has Git initialized it could be an issue. Also, if there is a file conflict in the local repo and the remote repo it'd require a merge - that's not difficult, but it's enough to frustrate someone already struggling with Git.
      So yes, your approach would work as well and isn't a bad approach. Here my goal is just a simple approach that should be fairly bullet-proof and avoid corner cases.
      Thanks for viewing!

    • @sharzoe
      @sharzoe 3 місяці тому

      @@cameronmcnz Actually, I just tried this and, unfortunately, it didn't work. After entering "git clone ...", I received an error message: "fatal: destination path already exists and is not an empty directory". Debbie Downer strikes again.
      This really sucks because I have a lot of established solutions that share multiple projects in Visual Studio. If I have to recreate the solutions because folders moved it could take a while and is prone to mistakes.

    • @cameronmcnz
      @cameronmcnz  3 місяці тому

      @@sharzoe Check the folder where you did the git clone for a subdirector with the same name as the GitHub repo. Does one already exist?
      If so, check if it has a hidden .git folder in it.
      It seems like you are trying to clone into a folder that already has a git repo initialized within it. If that's the case, Git will puke.
      Run the git clone command from a different directory, a fresh directory with nothing in it. See if that works.

    • @sharzoe
      @sharzoe 3 місяці тому +1

      @@cameronmcnz Running the git clone command on an empty folder works fine. Maybe I didn't state my problem correctly. I have a folder C:\Dummy\MyFolder. This folder has an existing c# project. I want to use this folder as my git repo. If I open the Git Bash window from C:\Dummy and issue a git clone for the MyFolder project I just created in Git, I get the error. Apparently because the folder is not empty.
      Why isn't there an easy way to take existing code and make it a git repo? This doesn't feel right. I don't want to spend days reconfiguring solutions that are already working fine.

    • @sharzoe
      @sharzoe 3 місяці тому +1

      Oh - and thanks so much for the very quick replies!

  • @HaifengZhu-pn3uq
    @HaifengZhu-pn3uq Рік тому +1

    When I right click on my computer, it doesn't have "Open Git Bash"

    • @cameronmcnz
      @cameronmcnz  Рік тому

      If you're using Windows, you need to install Git. But I've got you covered with this video on installing Git here:
      ua-cam.com/video/9CAwvKiLICs/v-deo.htmlsi=fszI9fIvBrDmT-Od

  • @gabehorno
    @gabehorno Рік тому +13

    I swear to god Git is the most confusing shit ever to use. It was easier to learn C++ than to use Github

    • @cameronmcnz
      @cameronmcnz  Рік тому

      I put together this Git and GitHub tutorial just for you. I'm going to make you love Git!
      ua-cam.com/video/l2yrJtwoC_E/v-deo.htmlsi=e8RJQt1T71B0u_zB

    • @berndblubb5243
      @berndblubb5243 9 місяців тому

      @@cameronmcnz
      I am afraid I have to ack @gabhorno's comment. All programs using subcommands seem to be overly complicated and obscured. I assume most programmer's just want to do a bit of version manament, without having to travel a long learning curve and get frustrated by confusing terms like origin, master, HEAD, and other badly explained terms.
      From my point of view for most smaller development teams systems like svn or even cvs are much better suited for their purposes than git.

    • @geriatricprogrammer4364
      @geriatricprogrammer4364 7 місяців тому

      Git stash deploy reinstated old versions of files...git is like a loaded gun and I'm the toddler playing with it about to blow my head off.

    • @uiscestudio
      @uiscestudio 16 днів тому

      You're not alone...I'm with you. (I haven't learned C++ however 🎉)

  • @mintiankai
    @mintiankai Рік тому +1

    Thanks. It is helpful.😀

  • @mindhealth4393
    @mindhealth4393 Рік тому +1

    The push* is not working for me. does anyone knows why. i am using mac. i got zsh: no matches found: push*

    • @cameronmcnz
      @cameronmcnz  Рік тому +1

      Are you on the main or master branch?
      Make sure the same branch exists both on the server and client.
      Git still defaults to master. GitHub to main.
      You might need to create a master branch on GitHub.

  • @fuhayho
    @fuhayho 9 місяців тому +1

    thanks for helping me LOL

    • @cameronmcnz
      @cameronmcnz  9 місяців тому

      You helped yourself by finding the resource you needed. That's what being a dev is all about - knowing how to find the answers. The only person to thank is yourself!

  • @اناهنا-ب3و
    @اناهنا-ب3و Рік тому +1

    How can I edit existing files?

    • @cameronmcnz
      @cameronmcnz  Рік тому

      The ones on GitHub or the ones locally on your file system? GitHub has an online editor for files you have pushed from your existing project to GitHub so long as you have appropriate permissions. Otherwise, just edit those files on the filesystem.

  • @arhampersonal
    @arhampersonal Рік тому +1

    thanks a lot ( :

  • @Naveen-l3h
    @Naveen-l3h Рік тому +1

    excellent

  • @AbstractCatsMedia
    @AbstractCatsMedia Місяць тому

    Not working

    • @cameronmcnz
      @cameronmcnz  Місяць тому

      @@AbstractCatsMedia what’s the error?

  • @Eag757
    @Eag757 Рік тому +1

    Academia think students have all day to work on a projects, and give instructions that were effective back in 2000's. Professors aren't adapt to fast pace modern world of tomorrow.

    • @cameronmcnz
      @cameronmcnz  Рік тому

      I'll try and stay up to date with my Git and GitHub tutorial!
      ua-cam.com/video/l2yrJtwoC_E/v-deo.htmlsi=e8RJQt1T71B0u_zB

  • @Broockle
    @Broockle 3 місяці тому +1

    The github culture is so strange. There's a perfectly good GitHub for Desktop tool with buttons and shit and you guys all type commands into a terminal.
    What is wrong with you 😅

    • @cameronmcnz
      @cameronmcnz  3 місяці тому

      We are indeed animals. I guess the thing is, there are so many different desktop apps. I've got long tutorials on GitKraken, Sourcetree and GitHub Desktop. They're all great tools. But underneath the covers, they just run these git commands. So I guess it's just the common demonimator we go for.

  • @mehmeteminmese979
    @mehmeteminmese979 Рік тому +1

    Is it that easy ??????🤣🤣🤣🤣

    • @cameronmcnz
      @cameronmcnz  Рік тому

      When you follow my git tutorials it is!!!