The goal of this workshop is to explain how to use Git / GitHub correctly
- Install Git
- Set up global username:
git config --global user.name "yourUsername"- check your global username:
git config --global user.name
- check your global username:
- Set up global email:
git config --global user.email "your@email.com"- check your global username:
git config --global user.email
- check your global username:
- checking for existing key:
ls -al ~/.ssh
- create a new key:
ssh-keygen -t rsa -b 4096 -C "your@email.com"Enter a file in which to save the key (/Users/you/.ssh/id_rsa):[Press enter]Enter passphrase (empty for no passphrase):[Type a passphrase]Enter same passphrase again:[Type passphrase again]
- adding your key to ssh-agent:
eval "$(ssh-agent -s)"return your Agent pid- On Mac Sierra 10.12.2 or later :
Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa
ssh-add -K ~/.ssh/id_rsa
- On Windows:
ssh-add ~/.ssh/id_rsa
- adding your key to your GitHub account:
- On Mac:
pbcopy < ~/.ssh/id_rsa.pub - On Windows:
clip < ~/.ssh/id_rsa.pub - Or just
cat ~/.ssh/id_rsa.puband manually copy the content - Go to your GitHub account:
- Settings > SSH and GPG keys > New SSH key
- Add a title:
Example: Personnal computer SSH key - Paste your public key
- Add your SSH key
- On Mac:
git init: create a new local repositorygit remote add origin <github repository>: connect your local repo to your distant repogit clone: clone your distant repo to a local folder- HTTPS:
git clone https://username/repo.git - SSH:
git clone git@github.com:username/repo.git
- HTTPS:
git status | gst: show only the files with modificationsgit add | ga:git add <file>: Add a specific filegit add . | ga .: Add all files with modifications
git commit | gc:git commit -m "commit message" | gc -m "commit message": commit your file with an informative message
git reset: reset all or specific files yiu have commitedgit stash: stock your changing file in a different place, so you can recover your changes in another branchgit stash list: display a list of your stashesgit stash apply stash@{$}: Recove your stash in your current branch
-
git pull / git pull origin <branch> | gl:git pull | gl: default pull command, likegit pull origin master. It'll recove the version of the code in themasterbranchgit pull origin <specific branch>: It'll recove the version of the code in a specific branch
-
git push / git push origin <branch> | gp:git push | gp: default push command, likegit push origin master. It'll send the version of the code in themasterbranchgit push origin <specific branch>: It'll send the version of the code in a specific branch
git checkout <branch> | gco <branch>: change your current branchgit checkout -b <branch> | gco -b <branch>: create a new branch and change to it
git branch: list all the branchesgit branch -d <branch>: delete a specific branch
- Fork this repository
- Create a branch with your username and work on it
- Copy this
atag, and paste it in thenavtag with your entire name, username and GitHub account URL.
<a href="https://github.com/unsername" title="username's github account">Firstname Lastname (username)</a>- Create a pull request with your modifications located on your username branch
- Send the pull request