Skip to content

AppsandThat/Week1Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 

Repository files navigation

:octocat: Git Your Practice On!

#UBC APP and THAT, WEEK 1: GIT PRACTICE

Instructions

#####NOTE: If you have questions, don't hestate to post on Piazza!

######1: Fork and Clone

  1. Fork this repository and then clone it onto your local machine
  2. Add your name (and whatever else you want) to the very bottom of this file
  3. Push your changes to your forked repository on github (not this one!)

######2: Fork and Pull

  1. Send me (this repo, not yours) a pull request!
  2. Replace you name with your github username in README.md and commit your changes
  3. Fetch your remote repo and merge it with your local one

######3: Issues 7. Create an issue on GitHub called: "Need moar ACII Arts" (or anyother name you want!) on GitHub. Add a description too! I'll close the issue when you've finished this exercise (step 10).

######4: Branching 8. Create a new branch with the name of your GitHub username. 9. Switch to your new branch and add some ASCII Art generate it here beside your name 10. Push your branch to your forked repo and then send me a pull request to the origin repo (at /AppsandThat/Week1Practice.git) 12. Switch back to your master branch and merge your new branch into your master branch 11. Delete your branch that you created in part 8 (only on your local repo)

######5: Finishing Up 12. Push the changes to your forked repo 13. Send me another pull request with your newly add ASCII Art 14. You're DONE! If you are still curious check out http://www.gitref.com or look below for more commands. Also try forking and editing our website repository here: [github.com/AppsandThat/AppsandThat.io](Apps n That repo). I've created a few issues for you to solve

##HELPFUL RESOURCES

##Useful & Common GIT Commands

git clone git@github.com:<user_name>/the-repo-you-are-cloning.git

Clones your remote origin repo locally

git fetch upstream

Pulls in the remote changes not present in your local repo. Downloads objects and references from another repository.

git merge upstream/master

Merges any changes fetched into your working files

git add <file>

Start tracking new files and also stage changes to already tracked files

git status & git diff

  • Tells us what files and assets have been modified and staged
git status -s

This will display what files have been removed, changed or modified.

  • (M) - modified
  • (A) - added
  • (AM) - file has not been altered since it was last added
git commit -m 'the message goes here for the commit'

Records a snapshot of the project into your history at the time of your commit.

git add '*.<file_extension>'

This command adds all file types with the same extension, especially from different directories. Without quotes the command will only execute within the same directory it's been called from.

git rm --cached <file>

Unstages a file from the working tree (i.e. stops tracking the file).

git log

Remembers all the changes we've committed so far, in the order we committed them.

git log --summary

See where new files were added for the first time or where files were deleted.

git remote add origin git@github.com:<user_name>/<repo_name>.git

Creates a brand new remote repository.

git remote -v

Show a list of the current remote repositories

git reset <file>

Removes the desired file from staging area.

git branch -r

List all the remote branches currently tracked

git remote prune origin

Deletes branch locally if it has been removed remotely. Helps to remove stale references.

git checkout -- <target>

Changes the desired target back to the state of the last commit. A target can be a file or a directory (for example).

git rebase

Rebase allows you to easily change a series of commits, reordering, editing, or squashing commits together into a single commit.

Be warned: it's considered bad practice to rebase commits which you have already pushed to a remote repo. Doing so may invoke the wrath of the git gods. https://help.github.com/articles/interactive-rebase

Adding

git add <list of files>

(i.e. git add readme.md license.txt. Can be multiples)

git add --all

Add all the new files since last

git add *.txt

Add all txt files in directory

Staging

git diff

Show unstaged differences since last commit

git diff --staged

Gets the staged differences and displays what has changed since our last commit

Reverting

git reset HEAD <file>

Head is the last commit on the current branch we are on. What if you stage something you didn't need to be staged? This is the key.

git checkout -- <file>

Reset all changes to a file since last commit

git reset --soft HEAD^

What if you regret a commit? This will undo your last commit. (^ means move commit before HEAD and puts changes into staging).

git reset --hard HEAD^

Traverse through commits and revert back one by one.

git reset --hard HEAD

Undo Last commit and all changes

git commit --amend -m "added another file to the commit'

New commit message will override previous commit message

Remotes

"Remotes are kinda like bookmarks"

git remote -v

Show the current remote repos

git remote add <name> <address>

Add a new remote repo

git remote rm <name>

Remove remote repo

Cloning, Branching, Fetching & Merging

git fetch

Pulls down any changes but doesn't merge them

git branch <branch name>

Makes a new branch

git checkout <branch name>

Switching branch and on a different timeline

git merge <branch>

Merges branch into master

git branch -d <branch name>

Deletes branch

git checkout -b <branch name>

Creates a new branch and then switches to it

:wq + enter

VI Editor Quick Key Exit

g fetch origin

git checkout -t <remote>/<branch>

Fetches a remote branch not available locally also reference issue #7

Pushing & Pulling

git push -u origin master (remote repo name[origin], local branch name[master])

Lets you just run git push later on without specifying name and branch

git pull

Pull changes in and syncs up your repo. Doesn't update local code

Branching

git branch -r

List all remote branches

git remote show origin

Show all the remote branches

git push origin :<branch name>

Deletes the remote branch

git branch -D <branch name>

Delete the local repo branch and if you don't want the commits any longer on it then delete them too.

git remote prune origin

Deletes the branch locally if it has been removed remotely. Helps to remove stale references.

Rebasing

"Merge commits are bad"

git rebase

Move all changes to master local which are not in origin/master remote to a temporary area

History

git log

Viewing the commits history

git config --global color.ui true

Color codes the commit SHA

git log --pretty=oneline

or

git log --graph --oneline --all

Commit and history is one line

git log --pretty=format:"%h

Exactly how you want the output using placeholders (use git help log)

git log --until <value>

Date Ranges. For example you could grab everything from the year 2013 using git log --until 2013

Removal

git rm <filename>

Removes file completely

git rm --cached <file names>

Won't be deleted from your file system, but keeps the local changes still.

Help

git help
git help <command>

DAVID BALDWIN

faithfullie h1t8@ugrad.cs.ubc.ca 777777777777777777777I?I77777777IIIIIIIIIIIIII7II???????+++=~~~=++======+++++++ 777777777777777777777I?III7IIIIIIIIIIII777IIIIIIIIIIII????III?======++==++++++++ 777777777777777777777?+==+?+++???????????II??????III?IIIIIIII+==========++++++++ 7777777777777777III??+====?+?II=+??++++??????????++++??+===============++++++ 77777777777III???????+++++?II?I7IIIIII?III?++=======================+++++++++++ 7777III??+???????????I?IIII?II??IIIIII??????II?=====================++++++++++++ I???????????????????IIIIII????????II??????+??III?===================++++=+++++++ ????????????????????I??????+++++???++?+????????II+=============++=++++++++++++++ +?????????????++??????+++?+++++++++++++++++?+++?II?===========+++==+++++++++++++ +=+?????????????????+++++++++++++++++++++=+?++++?I7+==========+++++=++++++++++++ ??+=+??????????????++++++++++++++++++=====++=++++?7I+========+++++++++++++++++++ ???++++??+++??????++++++++++====================++?77+===========+++++++++++++++ +++++++++++=+==+??+++++=+===================~~====+I7=====+++=======++++++++++++ +++++++++++++++???+++++==================~~~,,,==++7?===+++++++=====+==++++++++ ++++++++++?II?????++++=======~~~~===========:,,,===+77====++=+++++++=====+++++++ +++++++??????+++?++++++====:::::=======+==+=:,,===?II===============++++==++++ ++++++++????+++?++++++====:,,,,,~~=++++??+??????+=+=77+===========+==+++++==+++ +++++++++??++++?++=+++===:.,,.,,+====+=====+++III?77=========+++++++++++++++ ++++++++??++++?++==++++==:,,,,,:==+===,,,,,,==?II7?I7=======+++++++++++++++++ ++++++++++++++++++==+++==~~~::=+++==,,..,,.,=+I??777?===++++====+++=======++ ++++++++++++++++++=~+++======+++++==:..,,.,,~~=+=I7I7+?======+++++++++++++++ ++++++++?++++++++==++++=====+====+===:,,..,:~~~~=+77II7+===++++++++++++++++++ ++======?++++++++==++=======+++========:::,,::~~~~~++7I??++==+++==+++++++++++++ ===+==+++?+++++++==++=====+++==+=====~~~:::,::~~~~~=+I7=+============+=====+=== +=++=+++===+?++++===+=+===++==+======~~~::,,,,,~~~~=??I+======================= ============??++=====+==+++=====~~~:,::,,,,::,====+?=================+++++++ ============++++=======+==++=====::,,,,,,,,,:,,====+=I==================+==++++ ============++++===+===+==+=====,,,,::::,,::::==+??II=========+====+========++ ========+++==+++===?++=======~~~:,,,::::::::==??I7========================+ +====++==+++=====+??+====+=~~~==~~~~=:,,:=:::::,=+?III===================+=++=+ ++++==+==========+??++=+===~~~========,,,,,,,,:?I7777?====================++=+ +++=============+???+++==============~::,,,:?I77II?=====================+==== ========+=++++==+???++++=====================+?IIIII+======================== ========++++++==+???+++=====~~~==================+??III?+======================= ======+++++++++=+???++++==================+=+?IIIIII+====================== ====++++++++++==+??++++==========~~~=~~~======+?I7?III+===================== ===============+????++++=+====~~~~~~~~~=~~~=~~~~==++II??II?==================== ==============+????+++++===+=+==~~~~~=~~~~~~~~====???+?III?=~~~~~=============== =========~~~==+??++++++++=======~~~~========????+?II?================?+=== ======~~~~~~~+?+++++++++============~~~~~==~~~===+?I???II?===========++==+++++ ==~~~======+?++++++++=++========~~~=~~~~~=~~=======+??77+======+++=++=+===+?+

~~==~======~=++++++==++============~~~~~=~=~~~=======+?IIII~~~~========++===++++
~=====~~=====+++++==+++=============~~=~~~==~==~=====+?III?~==========~~~=+=++++
=========~~~~+??+++=++==============~~=~~~~~========+++?III~~~=+=+==========+===
=====~=====~=+?++++==+==============~~~~~~~~~========+I??II+~:~====+====~~~===~~
===~=========+?++++================~=~=~~~=~~~~~~=+==+++?II=~=~:~++===+==++=+===
===========~=?+++++=================~~~~~~=~~===~~~~===+?II+~~=~~~~==++++=======
~===~~~~~=~~~++++++========~========~~==~~==~~~====~===+?I7?~=~==~::~=?+=++===++
~~~~~~~~~~~~~+++++++======~=========~~~~~~=~~~~~~===~~=+??7?~~~=~=~:::=~=====+==
~~~~~~~~~~~:~+++++====================~~~~~~~~~=~~===~=++?II=~~~~=~~~::~========
~~~~~~~~~~~~++++++=========================~~~~~~=~=====+?II~~~~~~~===~::~======
~~~~~~:~~~~~~+++++=================~~==~==~~~~~~~~===+==+?II=~~~=~==~~==:~~=====
~~~~~~~~~~~~~+++++=====~==~~======~~~=~~~~~~~~~~~=~~~~~=+?7?~~~~~~==~=~=~~::~~~~
~~~~~~~~~~~~=++++=====~~~~=~~~~=~=~~~~~~~~~~~~~~~~~~~===+?II=~~~~=~~=~===~~~:~==
~~~~~~~~~~~~~++++====~~~=~~~~~~~~~~~~~~~~~~~~~~~~~~~~===+???~~=~~===~=~~~~=~~::~
~~~~~~~~~~~~~=++=====~~~~~~~==~~~~~~~=~=~=====~~~~~~====+II~~~~~~~~~===~===~~~::
~~~~~===~==~~=+++=======~~===+===========~====~~~~~===++?I?=~==~=~==~==========~
~~~~~~~==~~~~=++++======~====?+~~~~=~~==?+++===~~~===++??I+~~~~~~~=~======~~~=~~
~~=~~~~~~~~~~~=+++====~=====+?I??~===~~=??++==~~~====+??I?~~~~~====~~~+=~===~~~=
~~~=~~~~~~~~~~~+++====~=====+?I?+=~~~~:=??+====~~====+???~~~~~~~~~~~~===========
~~~~~~~~~~~~~~~~++====~~~===+?II?=~~~~+?++==========+?III=~~~~~~=~=~~~~=========
~~~~~~~~~~~~~~:~=++===~~~~===?III?+~~=+??+==========+II?=~~=~~~~~~~~~=~=~=======
~~~~~~~~~~:~~~~~~=+======~===+?III?~~~+++==========+?II=~~~====~=~==~~~~~=======
~~~~~~~~~~~~~:~~~~++==========+?II?=~++++===========?I~~~~~=========~=~===~~~~==
~~:::::~~~~~~~~~:~=++==========?II=~~+++===========+I?~~~~~~~~~~~=========~~~~~=
~:~::~~~~~~~~~~~~~~++====~=====+I+~:~=+++===~======?II=~~~~~=~~~~==~=~=~====~==~
:~~::~~~~~~~~~~~~~~~++===~~~==+?I?~:~=+++===~======+I+~:~~==~~~~~~~~~~~~====~~=~
~~~~~:~:::~:~~~~:~:~?++=======+I?~~~~==++=========+??+~~~~~~~~=~~~~~~~~=~=~=~~::
~~~:~~~~~~~~~~~~:~~??++=====~=+I?=:::~=++=========+?I=~~~==~~~~=~::~=~~~~==+=~==
:~~~~~~:~::::=~:~~=?++====~==++??~~~~~=++=========+???=~~==~~~~~~~:~~==~=~==~=~~
~~:~~~~~~~:~~:~~~:+++=====~===+?I~~~~~~+=======~=+++?II~~:~~=:=~=~~~~~~~~=~=~~~=
~~~::~~~:~~~~~~~~=+=======~===+?I~~~~~::=======~=~~+???:~~~~~~~~~~~==~~=~~~~~~~~
~::~~~~~~~~~~~~~::=+=~=~~====++++::~:~::~==========++I~~:~~::~~=:~~~=+=~=~~=~:~~
:~~:~~::~~~~~~:::::=~~=~~:~~~~~~~~~::::::::==~~=====?~=~::~~:~:~~~=:~~~+~~~~~=~:
::~:~~~~~~~:::~~:::~:~~:::~,,:~:~::::::::::::~~~~=~+:~:=~~==~~~~==:~~~~~~~~~:~~~
~~~~~:~~~~~::~~::~:::,,:,:::~::::::::::::::,:::,,,,::~:~~~:~:~~~~~~~~~:~~=:~~~~~