A practice git repository where you can eff up as much as you'd like plus work with a real, living, breathing person on the other side. Here we learn all things git. Feel free to send Pull Requests to see what it's like when someone asks you "Can you squash your commits for us" and you're all like "How the hell do I do that?"
HTML Python JavaScript C Java Ruby PHP
Switch branches/tags
Nothing to show
Clone or download
Latest commit 4253091 Jun 18, 2018
Permalink
Failed to load latest commit information.
branch1502 modification in test-file.txt Feb 15, 2018
norajs Add photo May 28, 2018
practice-git new testing Feb 23, 2017
Ania_file1 update file Jan 24, 2015
Diego_file Added Diego_File Jun 30, 2015
DonePracticing Create DonePracticing Oct 31, 2016
Myfile created file Jan 26, 2017
Penne_all_arrabiata.txt Added a new recipe Sep 2, 2015
Plan.png add png file to test Oct 23, 2015
README.md Updated bad link in wiki Sep 5, 2017
asas.txt add more comment to the asas Aug 9, 2017
bashIdioms Idiom for using anonymous pipes and subprocesses to sort and filter Sep 29, 2016
bits.py added bits.py Dec 4, 2016
blah.c merge with another line Feb 12, 2017
commit_resource.txt add commit_resource.txt Feb 18, 2018
deep_coder.c Practising on Git Feb 18, 2016
eva Create eva Sep 4, 2017
genesis_kjv This is my first new file May 19, 2017
github.php Revert "added comment for tutorial link" May 22, 2013
graezzon.md add graezzon.md Jun 16, 2018
harrypotter Create harrypotter Nov 20, 2017
hi.java Modify sop string in hi.java Jan 22, 2018
hiandy.html Minor edit after pull request has been made Apr 11, 2014
kacper.txt dodanie 1 Nov 18, 2017
lolol Create lolol Oct 31, 2016
mwGo.txt go, man go Nov 21, 2017
my_code.txt Add welcome in my_code.txt Jan 22, 2018
notes.txt 7th commit ... Apr 9, 2017
numberone first for me! Feb 21, 2017
pi.py added pi Oct 26, 2016
pizza_recipe.txt testing using sourcetree Aug 1, 2017
practice-First Create practice-First Feb 10, 2016
practy.js another one Dec 15, 2017
sample new file.txt line testing [2] Oct 28, 2017
table-test.html create table test Oct 28, 2017
test123 Create test123 Aug 8, 2017
testing.txt new testing Feb 23, 2017
touch.txt added a line Oct 9, 2017
touchmove.js Third Commit -- added notes.txt Dec 24, 2015
tst.md Update and rename tst.txt to tst.md Nov 3, 2017
universe.py added new universe function Jul 31, 2017
whatsup.rb corrected syntax on line 1 (5.times do) Feb 17, 2018
zen_of_python.py added a python script that generates some engineering advice Oct 9, 2017

README.md

:octocat: Git Your Practice On!

Welcome to my practice git repository where you can eff up as much as you'd like plus work with a real, living, breathing person on the other side. Here we learn all things git. Feel free to send me Pull Requests just to discover what it's like when a Repo Master asks you

"Can you squash your commits for us"

and you're all like...

"How the hell do I do that?"

This is where we make those mistakes ... so don't be scared :)

Instructions

Fork this repo and send me a Pull Request with anything from Grandma Peggy's Crumbled Oatmeal Cookie Recipe to your favorite Sublime Text 2 preferences. It's all good yo! Learning is the prize in this game.

Typical & Highly Useful 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>