Skip to content

wwcgitworkshop/GithubWorkshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 

Repository files navigation

Git Workshop

Github Cheat Sheet

Git Manual

Review help topics:

$ git help

TIP: exit help by simply typing q

Fork the remote respository

alt text

Create your local respository

Create a folder for the repository:

$ mkdir <folder_name>
$ cd <folder_name>

Clone the fork into your new folder:

$ git clone https://github.com/<username>/GithubWorkshop

Go into the git directory:

$ cd GithubWorkshop

Add 'upstream' repo to list of remotes: This isn't required, but we do it to keep our copy up to date with the remote

$ git remote add upstream https://github.com/wwcgitworkshop/GithubWorkshop

Verify the new remote named 'upstream':

$ git remote -v [-v | --verbose]

Open the Readme.md in your text editor

Create and modify a local branch

Review git branch:

$ git help branch

Create a new feature branch:

$ git branch <feature_yourname>
$ git checkout <feature_yourname>
$ git branch -a

shorthand version

$ git checkout -b <feature_yourname>

Create a new file: your_name.txt

Copy this into <your_name.txt> file:

 Your name:
 Why you came to the workshop?
 Is this your first event?
 Favorite ice cream flavor?
 What is the name of the person sitting to the right and left of you?
 Do you want to contribute to open source in the future? 

Check the status of your changes:

   $ git status

Your file is not being track by git, we need to add it

Add your_name.txt to the repo:

  $ git add <your_name.txt>
  $ git status

TIP: git add stages your changes. You cannot commit your changes until you have first staged them.

Check the status again to see the staged file:

  $ git status

Remove delete_me.txt from your repo:

  $ git rm delete_me.txt
  $ git status

Run a diff on the changes: good practice is to run a diff before every commit

   $ git diff origin

Commit your changes: "Commit early and commit often"

   $ git commit 
   $ git status

TIP: Use git commit, rather than the shorthand git commit -m "Add your commit message here"

Do a git log to see your changes:

   $ git log

Add a new line of text to your_name.txt

Run a diff on the changes:

   $ git status
   $ git diff origin

Stage your changes:

   $ git add .
   $ git status

TIP:
git add . stages new files and modifications, without deletions
git add -A stages all changes
git add -u stages modifications and deletions, without new files

Commit your changes:

   $ git commit

Push your branch to the remote:

   $ git push -u origin <feature_yourname>
   $ git status

TIP: You only need the -u command if your branch is not already upstream

Merge your branch into master

First review all the branches:

   $ git branch -a

Checkout Master:

   $ git checkout master 

Pull updates from the remote:

   $ git pull 

TIP: git pull merges changes from the remote into your local copy. Use git fetch if you simply want to download the latest to keep track of what is going on. You will then need to merge to incorporate the updates from fetch.

Fetch upstream master and merge with your repo's master branch

$ git fetch upstream
$ git checkout master
$ git merge upstream/master

TIP: If there were any new commits, you might want to rebase your development branch. More on that in the next session.

Now merge your changes into master:

  $ git merge <feature_yourname>

Push master to your origin:

   $ git push origin

Create your PR

Go to your github and click 'pull request'

Comapre changes and submit your message

Resolve any merge conflicts

Delete your branch

Once your PR has been merged, you should delete your feature branch

   $ git push --delete origin <feature_yourname>
   $ git branch -d <feature_yourname>

About

A simple repository to learn basic git commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •