Skip to content

Instantly share code, notes, and snippets.

@joladev
Last active August 29, 2015 14:25

Revisions

  1. Erik Kronberg revised this gist Jul 20, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ Some good resources:
    * [Code School Git Tutorial](https://try.github.io/levels/1/challenges/1)
    * [The Git Book](https://git-scm.com/book/en/v2/Getting-Started-Git-Basics)
    * [Git - The Simple Guide](http://rogerdudler.github.io/git-guide/)
    * [A Successful Git Branching Model](http://nvie.com/posts/a-successful-git-branching-model/)

    ## Repository

  2. Erik Kronberg revised this gist Jul 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Some good resources:

    ## Repository

    The starting point of using Git is the repository. A repository is a folder in which you've run the command `git init`. This command creates a hidden folder called `.git` that you basically never need to look at. Forget it exists. When working with git, you rarely need multiple folders. Comparing this with TFS, each branch gets its own folder. Instead, switching branches in a repo modifies all the files in the repo folder to look exactly like they did in the other branch. This is part of why branching in git is super fast and super useful.
    The starting point of using Git is the repository. A repository is a folder in which you've run the command `git init`. This command creates a hidden folder called `.git` that you basically never need to look at. Forget it exists. When working with git, you rarely need multiple folders. Compare this to the TFS where each branch gets its own folder. Instead, switching branches in a repo modifies all the files in the repo folder to look exactly like they did in the other branch. This is part of why branching in git is super fast and super useful.

    The most common command you will ever run is `git status`. This will print some information on the current status of the repository, including the current branch, changes staged to be committed, untracked file etc.

  3. Erik Kronberg revised this gist Jul 20, 2015. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,16 @@ Some good resources:
    * [The Git Book](https://git-scm.com/book/en/v2/Getting-Started-Git-Basics)
    * [Git - The Simple Guide](http://rogerdudler.github.io/git-guide/)

    ## Repository

    The starting point of using Git is the repository. A repository is a folder in which you've run the command `git init`. This command creates a hidden folder called `.git` that you basically never need to look at. Forget it exists. When working with git, you rarely need multiple folders. Comparing this with TFS, each branch gets its own folder. Instead, switching branches in a repo modifies all the files in the repo folder to look exactly like they did in the other branch. This is part of why branching in git is super fast and super useful.

    The most common command you will ever run is `git status`. This will print some information on the current status of the repository, including the current branch, changes staged to be committed, untracked file etc.

    Another informative command is `git log`. This will simply print a list of all the commits and some information. This command supports many different options, eg `git log --oneline`.

    After running `git init`, you also need to make an initial commit. Committing can be done either by typing `git commit` (which will open up a prompt for the commit message) or using a shorthand like `git commit -m 'my commit message'`. But if you try to commit now, git will tell you it doesn't know what you want committed. Anything you want added to a commit has to be "staged" first. This is done with the command `git add <filename>` or optionally, if you want everything staged, `git add .`.

    ## Commits

    A commit contains a diff of changes, a commit message (which consists of a title and an optional description), a checksum (which is essentially an ID), and a reference to the commit that precedes it. This way, all the commits form a chain you can follow back to the original. Git's history can only go in one direction, this is important to note when you do more advanced stuff with eg git rebase.
  4. Erik Kronberg revised this gist Jul 20, 2015. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,15 @@ Some good resources:
    * [The Git Book](https://git-scm.com/book/en/v2/Getting-Started-Git-Basics)
    * [Git - The Simple Guide](http://rogerdudler.github.io/git-guide/)

    What is a branch? A branch is a reference to a specific commit. Each commit tracks the previous commit, forming long chains of data packets, diffs, that together can be reassembled into data. Every time you make a new commit, the branch starts pointing at this new commit, and the commit remembers the previous one. Although a commit history can be modified and revised, doing this with commits that have been pushed to other repos is dangerous and leads to history conflicts.
    ## Commits

    A commit contains a diff of changes, a commit message (which consists of a title and an optional description), a checksum (which is essentially an ID), and a reference to the commit that precedes it. This way, all the commits form a chain you can follow back to the original. Git's history can only go in one direction, this is important to note when you do more advanced stuff with eg git rebase.

    ## Branches

    What is a branch? A branch is a reference to a specific commit. As described above, each commit tracks the previous commit, forming long chains of data packets, diffs, that together can be reassembled into data. Every time you make a new commit, the branch starts pointing at this new commit, and the commit remembers the previous one. Although a commit history can be modified and revised, doing this with commits that have been pushed to other repos is dangerous and leads to history conflicts.

    You can easily create and throw away branches. Branching takes milliseconds and switching between branches the same.

    ## Comparison to TFS

  5. Erik Kronberg revised this gist Jul 20, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    # Git 101

    Some good resources:
    * [Code School Git Tutorial](https://try.github.io/levels/1/challenges/1)
    * [The Git Book](https://git-scm.com/book/en/v2/Getting-Started-Git-Basics)
    * [Git - The Simple Guide](http://rogerdudler.github.io/git-guide/)

    What is a branch? A branch is a reference to a specific commit. Each commit tracks the previous commit, forming long chains of data packets, diffs, that together can be reassembled into data. Every time you make a new commit, the branch starts pointing at this new commit, and the commit remembers the previous one. Although a commit history can be modified and revised, doing this with commits that have been pushed to other repos is dangerous and leads to history conflicts.

    ## Comparison to TFS
  6. Erik Kronberg revised this gist Jul 20, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -18,3 +18,4 @@ In TFS, multiple people working on the same branch can get hairy fast. Not so mu
    * diff --stat
    * stash
    * bisect
    * tag
  7. Erik Kronberg revised this gist Jul 17, 2015. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,20 @@
    # Git 101

    What is a branch? A branch is a reference to a specific commit. Each commit tracks the previous commit, forming long chains of data packets, diffs, that together can be reassembled into data. Every time you make a new commit, the branch starts pointing at this new commit, and the commit remembers the previous one. Although a commit history can be modified and revised, doing this with commits that have been pushed to other repos is dangerous and leads to history conflicts.

    ## Comparison to TFS

    * Git is, unlike TFS or svn, a __decentralized__ version control system.
    * Git is, unlike TFS or svn, a __decentralized__ version control system.
    * Branches are much more lightweight, compared to TFS, and used in a different way.
    * Many possible workflows, eg merge vs rebase.

    In TFS, multiple people working on the same branch can get hairy fast. Not so much in git. But most git resources recommend making a lot of branches.

    ## The amazing things that Git does

    * rebase -i
    * cherry-pick
    * add -p
    * diff --stat
    * stash
    * bisect
  8. Erik Kronberg created this gist Jul 17, 2015.
    5 changes: 5 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Git 101

    ## Comparison to TFS

    * Git is, unlike TFS or svn, a __decentralized__ version control system.