Skip to content

⚙️ A repository that will help beginners to use Git & GitHub correctly.

Notifications You must be signed in to change notification settings

tanamanda13/git-github-ws

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Git / GitHub workshop

The goal of this workshop is to explain how to use Git / GitHub correctly

Set up git

  • Install Git
  • Set up global username: git config --global user.name "yourUsername"
    • check your global username: git config --global user.name
  • Set up global email: git config --global user.email "[email protected]"
    • check your global username: git config --global user.email

Create a SSH key

  • checking for existing key:
    • ls -al ~/.ssh
  • create a new key:
    • ssh-keygen -t rsa -b 4096 -C "[email protected]"
    • 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.pub and 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

Basics commands

Create / clone a repository

  • git init: create a new local repository
  • git remote add origin <github repository>: connect your local repo to your distant repo
  • git clone: clone your distant repo to a local folder
    • HTTPS: git clone https://username/repo.git
    • SSH: git clone [email protected]:username/repo.git

Interract with files

  • git status | gst : show only the files with modifications
  • git add | ga :
    • git add <file> : Add a specific file
    • git 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 commited
  • git stash : stock your changing file in a different place, so you can recover your changes in another branch
    • git stash list : display a list of your stashes
    • git stash apply stash@{$} : Recove your stash in your current branch

Send and recove versions

  • git pull / git pull origin <branch> | gl :

    • git pull | gl : default pull command, like git pull origin master. It'll recove the version of the code in the master branch
    • git 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, like git push origin master. It'll send the version of the code in the master branch
    • git push origin <specific branch> : It'll send the version of the code in a specific branch

Working with branches

  • git checkout <branch> | gco <branch> : change your current branch
    • git checkout -b <branch> | gco -b <branch> : create a new branch and change to it
  • git branch : list all the branches
    • git branch -d <branch> : delete a specific branch

Sources


To apply it

  • Fork this repository
  • Create a branch with your username and work on it
  • Copy this a tag, and paste it in the nav tag 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

About

⚙️ A repository that will help beginners to use Git & GitHub correctly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 100.0%