Giter Club home page Giter Club logo

gitting_better's Introduction

Gitting Better

We use git everyday, but sometimes forget that there's more than just push & pull

Git Core

  • Commit: code changes + parents + who dunnit + why
  • ref: just a reference
  • HEAD: ref to current commit
  • branch: named reference to some commit
  • tag: named reference to some commit
  • remote: repository where you'll look for commits

Getting started

  • Fork this repo!
  1. Question 1: Look at the initial commit in the repo. What's it's parent?
  2. Create a new branch, call it something creative like new_branch_<your_name>
  3. Push it up to your remote.
  4. Add a file in new_branch, called new_file.txt, and push it up. Take note of the commit sha
  5. Question 2: How do you find a commit's sha from the command line? in git ui?
  6. Oops! You meant to put something in new_file.txt. echo 'hello' > new_file.txt
  7. You don't want everyone to know how dumb you are
  8. Question 3: How do you fix your dumb commit without anyone knowing?
  9. Is the sha from your fixed commit the same as the on from your dumb commit?
  10. Let's play with merge conflicts
  11. Checkout conflicted_branch.
  12. Try to create a pull request to your master. Note that it won't merge, because there are merge conflicts
  13. Rebase to the rescue!! git rebase <upstream>/master, where is probably something like [upstream, origin]
  14. When you've successfully rebased, your git history should now look like
aa579eff8c13acfe3cefc3e75ed47ec543337f88 conflict it real good
4569fc69957f46c3dd1640d60def299883c070b2 Merge pull request #1 from schepedw/readme_gooder
0ef3f33870d4ee26291053fd5ae6249003c027f2 readme real gooder
c5eee65a95c3f012bdcf46d0b7df47a2c37c7f78 beginning of readme
  1. What about amending multiple commits?

  2. Maybe you're bad at committing. Maybe you put 'wip' as your commit messgae 9x in a row. Either way, it's time to make things prettier.

  3. Checkout the branch terrible_commit_history

  4. Look at the history

  5. Rewind to a point before your (my) terribleness started

  6. Consolidate to commits that make sense

  7. Push em up

  8. You've discovered that your project collaborators can't push commits to new_branch, because it's on your remote.

  9. Question 4: How do you 'move' a branch from your remote to a different one?

Credit where it's due

These exercises come from a lecture Kyle Hargraves gave at Enova 4/15/15. You can find the slides here if you're an Enova employee. Otherwise.. well, we're probably hiring ;)

gitting_better's People

Contributors

tall-dan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.