A brief intro to git

I was recently asked to speak about and provide insight into git at a meetup I’ve been running with a friend. As a developer, a version control system is a critical part of your toolkit, no matter the size of the project or team you may find yourself working on.

I first started learning to use git by applying it to my own projects and maintaining local repositories to track those projects. From there I moved on to hosting and storing my git repositories at Bitbucket while still working independently. My first experience with working alongside other developers in git came at my first full time development job on a small team (think really small — two developers, myself included). I picked up the basics of branching, handling merges, developing different features in parallel and, ultimately, dealing with QA and production deployments that were sourced from various branches in our project repository.

I’ve expanded on my knowledge git in the jobs I’ve held since that first position and have used svn pretty heavily as well (I don’t mind it, but I don’t love it — I’d argue git is the better choice for a number of reasons, its decentralized nature and flexibility being chief among them).

One of the many appeals of git is its flexibility and there are a wide range of commands that come with it. To get started, I’d suggest digging in with the following:

# initialize git
git init

# clone repo
git clone <repo url>

# view the state of the repo
git status

# this will stage all of your modified and/or untracked files for commit
git add -A

# this will stage only the files that you pass into the command as an argument, delimited by a space
git add <path to file(s)>

# this will commit all modified files and apply the commit message that follows it
git commit -am "<commit message>"

# this will commit only the files that you've staged and apply the message that follows it
git commit -m "<commit message>"

# amend the last commit message
git commit --amend

# this will fetch changes from the remote branch that you're currently on; this will require a merge if your local copy of the branch has diverged from the remote
git pull

# you can also specify arguments and branches with git pull, for example
git pull origin master

# this will checkout a different branch from the branch you're currently on
git checkout <branch name>

# alternatively you can revert the state of your current branch to match the head of that branch, or that of of an individual file
git checkout .

git checkout <path to file>

# check out a new branch, diverging from the current branch
git checkout -b <branch name>

# see available branches
git branch

# delete a branch locally
git branch -d <branch name>

# delete a branch remotely
git push origin --delete <branch name>

# merge a branch into the branch you're currently on
git merge <branch name>

# stash your current changes and return to the head of the branch you're on
git stash

# reapply your stashed changes
git stash apply

# reapply your topmost stashed changes and discard the change set
git stash pop

# show commit logs
git log

# show the reference log of all recent actions
git reflog

# fetch remote branches
git fetch

# throw away uncommitted changes and revert to the head of the branch (destructive command)
git reset --hard HEAD

# back branch up to previous commit
git checkout <commit hash value>

# revert a previous commit
git revert <git commit hash value>

Each of these commands has numerous options associated with it and allows for broad control over the flow and history of your project. There are a number of other options I’d suggest for learning more about git:

Lawsuit seeks records of FCC net neutrality discussions

Via Ars Technica:

“The FCC has made it clear that they’re ignoring feedback from the general public, so we’re going to court to find out who they’re actually listening to about net neutrality,” American Oversight Executive Director Austin Evers said in the group’s announcement of its lawsuit.

They’re listening to ISPs and their lobbyists — they could care less about the public.

Lawmakers blast FCC net neutrality rollback

Via Motherboard:

“To date, most of the FCC’s actions have ignored the needs of consumers,” said Rep. Frank Pallone, the New Jersey Democrat. “Too often, when given the choice, this FCC has sided with large corporations to the detriment of hardworking Americans.”

“Chairman Pai, in the time you have been the head of this agency, we have seen an agenda that is anti-consumer, anti-small business, anti-competition, anti-innovation, and anti-opportunity,” said Rep. Mike Doyle, the Pennsylvania Democrat. “I am deeply concerned that the FCC is on the wrong a path, a path that will hurt small businesses, regular people, and some of the most innovative sectors of our economy.”

The current incarnation of the FCC is entirely pro-industry and anti-consumer in its approach to regulating the market it oversees.

Chairman Pai’s argument is misleading at best, particularly given the admission of ISPs that the current net neutrality rules have not harmed investment. Should the current rules be repealed, ISPs likely won’t materially increase their infrastructure investments. Instead they’ll use the lack of oversight and regulations to line their pockets at the expense of competitors that require access to their networks and consumers that have no other choice but to pay for their service when selecting an internet service provider.

Via Ars Technica:

“Although you stated the [September 7] hearing was an inquiry into the ‘Internet ecosystem,’ you once again failed to recognize how important the Internet is for consumers, small businesses, entrepreneurs, political organizers, public interest groups, and people looking for work,” Doyle and Frank Pallone, Jr. (D-N.J.) said

Verizon argues throttling isn't throttling

Via The Verge:

“Video optimization is a non-discriminatory network management practice designed to ensure a high quality customer experience for all customers accessing the shared resources of our wireless network,” a spokesperson said.

Throttling is throttling. The justification on Verizon’s part doesn’t matter — they should be passing through traffic without filtering it.

Senator attacks ISP and FCC argument for net neutrality repeal

Senator Edward Markey, via Ars Technica:

ISPs are quick to tell the FCC and the public that Title II is harming network investment, but they have presented a much rosier view when talking to investors.

ISPs are already investing in infrastructure with existing regulations in place. They want net neutrality restrictions repealed so that they can more freely continue their existing abusing and anti-competitive behavior1.

A better fix for this problem would be to encourage more competition in the market, rather than shred regulations covering existing companies with near-monopoly positions and an extensive track record of anti-competitive and customer-hostile behavior.

  1. If ISPs are threatened by Netflix, they should try competing by creating a service that doesn’t suck.