Jump to content

Help with using GitHub

I am currently learning how to use GitHub. So far I have seen how to create branches and issue pull requests etc. and I am now looking at how to fork repos.

My question is, what is the intended way to use GitHub?

Say I want to contribute to a project. Do I fork it to my account, clone it on my pc, work on it and when I'm done commit and push the changes to my account repo and create a pull request to the original repo?

 

I am also having trouble pushing changes from my pc to my GitHub account using Git Bash. I was able to do it with the Desktop app, but I still want to know how to do it with Git Bash.

In an attempt to push the changes with Git Bash I wrote "git push", and Git Bash got stuck like in the pic attached. For future reference, how do I unstuck Git Bash?

gitbash_stuck.png

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Adonis4000 said:

Say I want to contribute to a project. Do I fork it to my account, clone it on my pc, work on it and when I'm done commit and push the changes to my account repo and create a pull request to the original repo?

Correct

 

1 hour ago, Adonis4000 said:

For future reference, how do I unstuck Git Bash?

Ctrl+C

 

Since you have added a 2nd remote you may want to add the remote name to the push.

 

Also you'll likely need to authenticate to push, if nothing happens it might be because your push opened a Windows authentication dialog in the background that you didn't see, and it's waiting for you to fill that up.

 

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, Kilrah said:

Also you'll likely need to authenticate to push, if nothing happens it might be because your push opened a Windows authentication dialog in the background that you didn't see, and it's waiting for you to fill that up.

It prompted me to login for verification but something went wrong and I just closed the tab. The process though did not end, that's why Git Bash got "stuck".

 

20 minutes ago, Kilrah said:

Since you have added a 2nd remote you may want to add the remote name to the push.

I'm not sure what remote means to be honest, or how to add the remote name to push.

 

In the end to push changes from local to my GitHub account I used:

git commit -am "changed abc"

git push

 

26 minutes ago, Kilrah said:

Correct

Thank you very much for confirming this.

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Adonis4000 said:

I'm not sure what remote means to be honest

You can have multiple repos you push/pull to/from. For example your repo is the main ("origin") repo, but if it's a fork from another repo you might want to add that as a 2nd remote (which it seems you did?) so that you can pull changes from the original to integrate into yours. 

 

9 minutes ago, Adonis4000 said:

or how to add the remote name to push.

 

git push <remote> <branch>

 

https://www.atlassian.com/git/tutorials/syncing/git-push

 

Using a GUI makes things a lot easier to do and understand. I tend to use Sourcetree, haven't really tried github desktop.

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Kilrah said:

if it's a fork from another repo you might want to add that as a 2nd remote (which it seems you did?)

Yes, I was following this https://docs.github.com/en/get-started/quickstart/fork-a-repo quickstart guide.

 

11 minutes ago, Kilrah said:
git push <remote> <branch>

I tried making local changes to the files and then

git push origin new-branch1

which prompts the error: failed to push some refs to 'https://github.com/Tony-4k/Spoon-Knife.git'

I assume that by editing my local files it makes changes to the main instead of the branch I want to push to. How can I edit a branch?

 

I also tried

git push origin :new-branch1

which deleted the "new-branch1" that I had created.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

After changing the files you commit the changes. That adds them to the branch, and then you can push the new state of the branch to the server.

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Adonis4000 said:

which prompts the error: failed to push some refs to 'https://github.com/Tony-4k/Spoon-Knife.git'

I assume that by editing my local files it makes changes to the main instead of the branch I want to push to. How can I edit a branch?

If you want to work on a different branch you'll  have to create it first. You can view the branches you have with "git branch". A new one can be created with "git branch <newname>". Then you switch to that branch via "git checkout <branchname>". Creating and switching to it at the same time can be done in a one liner as "git checkout -b <new branch>". After that is done you make your changes on the new branch and then push with "git push <remote> <newbranch>".

 

You can also push across branches with "git push <source branch>:<destination branch>", but that can potentially give headaches so I don't like that personally.

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9370 | CPU: i5 10510U | RAM: 16 GB

Server: CPU: i5 4690k | RAM: 16 GB | Case: Corsair Graphite 760T White | Storage: 19 TB

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×