Git Video Tutorial 4

Git Video Tutorial 4In this part of my git video tutorial I will answer a bunch of questions I have received. We’ll cover how to generate and use SSH keys locally as well as on GitHub. We’ll then look at how to set up multiple GitHub accounts on one computer. Through this you’ll easily be able to change accounts with one simple command. Then we’ll look at some examples on how the Fork & Pull workflow works on GitHub.

A transcript / cheat sheet follows the video below.

If you like videos like this, it helps my search ranking when you share this on Google Plus with a click here [googleplusone]

Previous Git Video Tutorial Videos

Init, Add, Commit, Status, Diff, Rm, Log and Installation :

GitHub, Remote Repositories, Push, Pull, Remote, Fetch, Tagging, Aliases and Clone :

Branching, HEAD, Checkout, Rebasing, Reverting, Reset, Clean, Solving Merge Conflicts and Mergetool :

Git Video Tutorial 4 Transcript / Cheat Sheet

---------------- GIT PART 4 ----------------

1. Here I'll demonstrate a workflow option with git called Fork 7 Pull. I'll also answer some questions I've received like how to work with multiple GitHub accounts on the same computer. 

---------------- GENERATING SSH KEYS ----------------

2. SSH keys allow you to identify trusted computers without the need for passwords and here I'll show you how to generate multiple codes for multiple GitHub accounts. 

a. ssh-keygen -t rsa -C "Your Email Address" # Generates the key

3. Then you have to define the name of the file you want to save the key in

4. A public key and a randomart image are generated. The randomart image is provided because it is easier to recognize then a random string of numbers.

5. cd ~/.ssh # Takes us to the location of our keys

6. I'll open the public key with vim

7. Now I'll copy the entire key from ssh-rsa till the end with my email

8. Got to GitHub and sign in

9. Click on account settings

10. Click on SSH

11. Give the key a name, paste in the key and click add key

12. Your public key is then listed

---------------- CREATING MULTIPLE GITHUB ACCOUNTS ----------------

13. Now I'll create another ssh key for a completely new account on GitHub
	ssh-keygen -t rsa -C "Your Email Address" # Generates the key

14. Give it a name

15. A public key and randomart are generated again

16. cd ~/.ssh # Takes me to the location for the keys
	ls # Lists everything in the directory
17. Go to GitHub again using a different GitHub account and click Account Settings

18. vim # Get the new key that was generated

19. Copy the key

20. After you click SSH Keys in the sidebar on GitHub, paste the key in, give it a title and click Add Key

21. We used a unique name for our keys so we have to tell ssh about them.
	ssh-add ~/.ssh/derekbanas
	ssh-add ~/.ssh/newthinktank
22. touch ~/.ssh/config # Creates the empty file config
	vim config # Open config
23. We are defining which account we want to work with by associating a keyword to our 2 different hosts.

	User git
	IdentityFile ~/.ssh/derekbanas
Host github-ntt
	User git
	IdentityFile ~/.ssh/newthinktank
24. Change to the directory you want to use on GitHub

25. This is the account on GitHub that holds the original master files

26 - 28. After I edit some files I stage them and commit them

29. git remote add myorigin git@github-ntt:newthinktank/CrazyTipCalc.git

a. Create an alias for our remote directory

b. github-ntt # I identify myself using the newthinktank ssh key

c. newthinktank/CrazyTipCalc.git # The specific files I want on GitHub

30. git push myorigin master
When you try to push to GitHub you may see this warning. You can verify you are pushing to GitHub by comparing the public keys

31 - 34. You can see GitHubs public keys here

35 - 37. Log into GitHub using my derekbanas account and search for the directory I have associated with my newthinktank account

38 - 41. Get the URL from GitHub and I can clone it
git clone  

---------------- FORK & PULL WORKFLOW ----------------

The way the Fork & Pull works is that anyone can Fork a repository and make changes locally. They don't have the ability to push their potentially damaging code. They can however request that the host repository pull their changes if they would like using a Pull Request. ( This is a very common workflow in the open source community )

42. Find a repository you'd like to work on and click Fork in GitHub

43 - 45. git clone
	# Get the URL for the fork on GitHub and clone it on your local computer

46. git remote add upstream
	# Assigns the original remote and not the fork to the keyword upstream
47. git fetch upstream
	# Pull in changes made in the original repository with effecting the local files

48 - 53. I can change a file locally, stage and commit it. I can then push it to more Fork on GitHub.

54. git merge upstream/master # Merges files on GitHub with my local files

55. If I think my changes should be merged with the original repository I can make a Pull Request. Click on Compare, review, create a pull request on GitHub.

56. Changes are listed as well as other data associated with your Forked version. Click the button labeled Create Pull Request if you think you're ready.

57 - 58. Leave a detailed reason why the Pull Request should be excepted and click Send Pull Request

59. The owner of the original repository can see how many Pull Requests they have received on the right side of the screen.

60 - 63. They can go through the Pull Requests and decide what to do.  

64 - 65. To merge click Merge Pull Request in GitHub and then leave a detailed explanation why it was done.

Leave a Reply

Your email address will not be published.