Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jasnow/practice-git-with-rails

Practice Git on a Rails repo
https://github.com/jasnow/practice-git-with-rails

rails-application tutorial

Last synced: 2 days ago
JSON representation

Practice Git on a Rails repo

Awesome Lists containing this project

README

        

Git Your Practice On with Rails!
============

** Please do not change the database from sqlite3 in dev/test.**

(originally part of PHP repo: https://github.com/grayghostvisuals/Practice-Git)

* Git Reference [http://gitref.org/basic](http://gitref.org/basic)
* Pro Git Online Book [http://git-scm.com/book](http://git-scm.com/book)
* Git Ready [http://gitready.com](http://gitready.com)
* Quick Command Practice [http://try.github.com](http://try.github.com)
* Git Real [http://www.codeschool.com/courses/git-real](http://www.codeschool.com/courses/git-real)
* How to GitHub: Fork, Branch, Track, Squash and Pull Request [http://gun.io/blog/how-to-github-fork-branch-and-pull-request](http://gun.io/blog/how-to-github-fork-branch-and-pull-request)
* Learn Git Online [http://learn.github.com/p/intro.html](http://learn.github.com/p/intro.html)
* Git: The Simple Guide [http://rogerdudler.github.com/git-guide](http://rogerdudler.github.com/git-guide)
* Git Immersion [http://gitimmersion.com](http://gitimmersion.com)

My References:
* http://pcottle.github.io/learnGitBranching
* http://net.tutsplus.com/articles/general/team-collaboration-with-github
* https://github.com/GarageGames/Torque2D/wiki/Pull-Requests-Coding-Standards
* https://github.com/skyscreamer/yoga/wiki/GitHub-Best-Practices
* http://codeinthehole.com/writing/pull-requests-and-other-good-practices-for-teams-using-github
* http://blog.8thcolor.com/2013/05/git-tips-and-tricks-2

Welcome to my practice git repository where you can change 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 Maintainer 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 (Contributing)

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 and highly useful git commands

``git clone [email protected]:/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/main``
* Merges any changes fetched into your working files

``git add ``
* Start tracking new files and also stage changes to already tracked files

``git status`` and ``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 '*.'``
* 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 ``
* 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 [email protected]:/.git``
* Creates a brand new remote repository.

``git remote -v``
* Show a list of the current remote repositories

``git reset ``
* 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 ``
* 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](https://help.github.com/articles/interactive-rebase).
* 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](https://help.github.com/articles/interactive-rebase)

##Adding
``git add ``
(i.e. git add read me.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 unstated differences since last commit

``git diff --staged``
Gets the staged differences and doisplays what has changed since our last commit

##Reverting
``git reset HEAD ``
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 -- ``
Blow away all changes to a file since last commit

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

``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

``
Add a new remote repo

``git remote rm ``
Remove remote repo

##Cloning, Branching, Fetching & Merging
``git fetch``
Pulls down any changes but doesn't merge them

``git branch ``
Makes a new branch

``git checkout ``
Switching branch and on a different timeline

``git merge ``
Merges branch into main

``git branch -d ``
Deletes branch

``git checkout -b ``
Creates a new branch and then switches to it

VI Editor Quick Key Exit
``:wq + enter``

##Pushing & Pulling
``git push -u origin main (remote repo name, local branch name) -u``
Lets you just run git push later on without specifying name and branch

``git pull``
Pull changes in and syncs up your repo

``git pull``
Fetches or syncs local with remote 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 :``
Deletes the remote branch

``git branch -D ``
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 main local which are not in origin/main 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 )

``Date Ranges``
Git log --until

##Removal
``git rm ``
Removes file completely

``git rm --cached ``
Won't be deleted from your file system just keeps the local changes still

##Help
``git help``
``git help ``

##Suggestions
* Add .ruby-version
* Add .ruby-gemset
* Remove public/index.html file
* Add "1 == 1" test.
* Add "1 == 1" rspec spec.
* Set up and deploy to Heroku.

**Enjoy**

3. Push it back to Github.

##DISCUSSION

If you have questions, please use this [Linkedin group](http://www.linkedin.com/groups/Atlanta-Ruby-Users-Group-106945/about)

##License

This repo is released under the [MIT License.](MIT-LICENSE.txt)

http://www.opensource.org/licenses/mit-license