DEV Community

Helen Kent
Helen Kent

Posted on • Updated on

How to use the terminal & github to make a pull request

I recently learned how to use the terminal with github (thanks to the very lovely people at codebar Birmingham!) I had to write down all the commands otherwise there is no chance I'd remember them all. There they are:

To update the fork on my machine (bring down all the changes from the repository on github so I have the most up to date version to work with) - You don't need to do this if you're the only one working on the project as it'll always be the most up to date version.

git checkout master
git pull
Enter fullscreen mode Exit fullscreen mode
git pull upstream master 
Enter fullscreen mode Exit fullscreen mode

If you make changes to the files and want to make a pull request, this is the sequence of things you need to do:
1) To see changes you've made

git status
Enter fullscreen mode Exit fullscreen mode

2) Add the file to the next commit

git add nameofthefile

OR if you want to add all files in the directory including new ones

git add .

ORRR if you want to add all files and new ones in the directory and also any other files in other directories within this root folder

git add --all
Enter fullscreen mode Exit fullscreen mode

3) Repeat step one to see the changes you've made that have now turned green (or changed colour depending on terminal settings?)

git status
Enter fullscreen mode Exit fullscreen mode

4) Type the following and then type out your commit message. Best to do this in bullet points and if you're fixing a particular issue - include 'Issue #24' for example to link it to the issue.

git commit
Enter fullscreen mode Exit fullscreen mode

5) In terminal the ^ arrow means ctrl. So click ^o to write code (save)

6) I didn't need to change the file name for this so then pressed enter and ^x

7) So far you've only sent it to the git on your computer - now you need to send it to the repository/fork on GitHub, so type:

git push
Enter fullscreen mode Exit fullscreen mode

8) Now open your browser and go to the github website.
9) Go to my repos and open up the one you're working on.
10) Click on pull requests
11) Select 'New pull request'
12) Type in any extra detail needed and send. Then that's it.

To add an extra page to a repo, just copy and paste a current one in my own folder on my comp, change what needs changing and then do as above.

To make my own github repo:
1) Click 'new' the github site and initialise with readme file.
2) Clone it.
3) Make a folder on my comp and locate it in the terminal. From inside that folder, type:

git clone https://github.com/helen8297/Helensfirstgithub.git
Enter fullscreen mode Exit fullscreen mode

4) When making changes, complete the above and then when you've done git push, that has sent it and that's it.

Useful future tip:
If I ever get a new computer, type the following in to do something good in the terminal - no idea what it means.

git config --global core.editor "nano"
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
scrabill profile image
Shannon Crabill

It looks like this command changes the default editor for your git commits

git config --global core.editor "nano"
Collapse
 
cngjo profile image
Johannes Przymusinski

Yes, core.editor configured the default editor for git. You could set it to „code“ for VSCode or „vim“, „emacs“ and what so ever. Remember you need to have the configured editor installed on your system 🙈 and yea, I Fall over this a few times on fresh installed machines. Setting it to „nano“ is a good choice in my opinion, specially if you’re using git in the commando line. Nano it Self runs there and you dont have to leave 😉 and it it pretty simple and self explaining to use. No need to google „how to exit nano“

Collapse
 
helen8297 profile image
Helen Kent

Ah thank you! I remember him saying something like that but wasn’t quite sure