From c0a20ed6e691e2cb03fdfef071d4d4e6500a055e Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 15 Jul 2013 18:11:37 -0500 Subject: rough draft --- git.html.markdown | 416 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 416 insertions(+) create mode 100644 git.html.markdown diff --git a/git.html.markdown b/git.html.markdown new file mode 100644 index 00000000..fd245e3c --- /dev/null +++ b/git.html.markdown @@ -0,0 +1,416 @@ +--- + +language: git +contributors: + - ["Jake Prather", "http://github.com/JakeHP"] +filename: LearnGit.txt + +--- + +Git is a distributed version control and source code management system. + +Git does this through a series of snapshopts of your project, and it works +with those snapshots to provide you with functionality to version and +manage your source code. + +In layman's terms, it's a way of managing, and keeping a detailed historical record, +of your source code. + +``` + +/////////////////////////////////////// +// Concepts +/////////////////////////////////////// + + /////////////////////////////////////// + // What is version control? + /////////////////////////////////////// + + Version control is a system that records changes to a file, or set of files over time. + + /////////////////////////////////////// + // Centralized Versioning VS Distributed Versioning + /////////////////////////////////////// + + [Detailed Information & Images.](http://git-scm.com/book/en/Getting-Started-About-Version-Control) + + /////////////////////////////////////// + // Why Use Git? + /////////////////////////////////////// + + * Can work offline. + * Collaborating with others is easy! + * Branching is easy! + * Merging is easy! + * Git is fast. + * Git is flexible. + + /////////////////////////////////////// + // Repository + /////////////////////////////////////// + + A set of files, directories, historical records, commits, and heads. Imagine it as a source code datastructure, with the attribute that each source code "element" gives you access to its revision history, among other things. + + A git repository is comprised of the .git directory & working tree. + + /////////////////////////////////////// + // .git Directory (component of repository) + /////////////////////////////////////// + + The .git directory contains all the configurations, logs, branches, HEAD, and more. + [Detailed List.](http://gitready.com/advanced/2009/03/23/whats-inside-your-git-directory.html) + + /////////////////////////////////////// + // Working Tree (component of repository) + /////////////////////////////////////// + + This is basically the directories and files in your repository. It is often referred to + as your working directory. + + /////////////////////////////////////// + // Index (component of .git) + /////////////////////////////////////// + + The Index is the staging area in git. It's basically layer that separates your working tree + from the Git repository. This gives developers more power over what gets sent to the Git + repository. + + /////////////////////////////////////// + // Commit + /////////////////////////////////////// + + A git commit is a snapshot of a set of changes, or manipulations to your Working Tree. + For example, if you added 5 files, and removed 2 others, you create a commit (or snapshot). + This commit can then be pushed to other repositorys. + + /////////////////////////////////////// + // Branch + /////////////////////////////////////// + + A branch is essentially a pointer that points to the last commit you made. As you commit + this pointer will automatically update and point to the latest commit. + + /////////////////////////////////////// + // HEAD and head (component of .git) + /////////////////////////////////////// + + HEAD, is a pointer, to the current branch. A repository only has 1 active HEAD. + head, is a pointer, that points to any commit. A repository can have any number of heads. + + +/////////////////////////////////////// +// Commands +/////////////////////////////////////// + + /////////////////////////////////////// + // init + /////////////////////////////////////// + + Purpose: + To create an empty Git repository. The Git repository's settings, stored information, + and more is stored in a directory, or folder named, ".git". + + Examples: + $ git init + + /////////////////////////////////////// + // config + /////////////////////////////////////// + + Purpose: + To configure settings. Whether it be for the repository, the system itself, or global + configurations. + + Examples: + + // Print & Set Some Basic Config Variables (Global) + $ git config --global user.email + $ git config --global user.name + + $ git config --global user.email "MyEmail@Zoho.com" + $ git config --global user.name "My Name" + + [Learn More About git config.](http://git-scm.com/docs/git-config) + + /////////////////////////////////////// + // help + /////////////////////////////////////// + + Purpose: + To give you quick access to an extremeled detailed guide of each command. Or to + just give you a quick reminder of some semantics. + + Examples: + // Quickly check available commands + $ git help + + // Check all available commands + $ git help -a + + // Command specific help - user manual + // git help + $ git help add + $ git help commit + $ git help init + + /////////////////////////////////////// + // status + /////////////////////////////////////// + + Purpose: + To show differences between the index file (basically your working copy/repo) and the current + HEAD commit. + + Examples: + // Will display the branch, untracked files, changes and other differences + $ git status + + // To learn other "tid bits" about git status + $ git help status + + /////////////////////////////////////// + // add + /////////////////////////////////////// + + Purpose: + To add files to the current working tree/directory/repo. If you do not git add files to the + working tree/directory they will not be included in commits! + + Exmaples: + // add a file in your current working directory + $ git add HelloWorld.java + + // add a file in a nested dir + $ git add /path/to/file/HelloWorld.c + + // Regular Expression support! + $ git add ./*.java + + /////////////////////////////////////// + // branch + /////////////////////////////////////// + + Purpose: + Manage your branches. You can view, edit, create, delete branches using this command. + + Examples: + // list existing branches & remotes + $ git branch -a + + // create a new branch + $ git branch myNewBranch + + // delete a branch + $ git branch -d myBranch + + // rename a branch + // git branch -m + $ git branch -m myBranchName myNewBranchName + + // edit a branch's description + $ git branch myBranchName --edit-description + + /////////////////////////////////////// + // checkout + /////////////////////////////////////// + + Purpose: + Updates all files in the working tree to match the version in the index, or specified tree. + + Examples: + // Checkout a repo - defaults to master branch + $ git checkout + // Checkout a specified branch + $ git checkout -b branchName + + /////////////////////////////////////// + // clone + /////////////////////////////////////// + + Purpose: + Clones, or copys, an existing repository into a new directory. It almost adds + remote-tracking branches for each branch in the cloned repo. (which allows you to push + to a remote branch) + + Examples: + // Clone learnxinyminutes-docs + $ git clone https://github.com/adambard/learnxinyminutes-docs.git + + /////////////////////////////////////// + // commit + /////////////////////////////////////// + + Purpose: + Stores the current contents of the index in a new "commit". This commit contains + the changes made and a message created by the user. + + Examples: + // commit with a message + $ git commit -m "Added multiplyNumbers() function to HelloWorld.c" + + /////////////////////////////////////// + // grep + /////////////////////////////////////// + + Purpose: + Allows you to quickly search a repository. + + Optional Configurations: + // Thanks to Travis Jeffery for these + // Set line numbers to be shown in grep search results + $ git config --global grep.lineNumber true + + // Make search results more readable, including grouping + $ git config --global alias.g "grep --break --heading --line-number" + + Examples: + // Search for "variableName" in all java files + $ git grep 'variableName' -- '*.java' + + // Search for a line that contains "arrayListName" and, "add" or "remove" + $ git grep -e 'arrayListName' --and \( -e add -e remove \) + + Google is your friend for more examples + [Git Grep Ninja](http://travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja) + + /////////////////////////////////////// + // log + /////////////////////////////////////// + + Purpose: + Display commits to the repository. + + Examples: + // Show all commits + $ git log + + // Show X number of commits + $ git log -n 10 + + // Show merge commits only + $ git log --merges + + /////////////////////////////////////// + // merge + /////////////////////////////////////// + + Purpose: + "Merge" in changes, from external commits, into the current branch. + + Examples: + // Merge the specified branch into the current. + $ git merge branchName + + // Always generate a merge commit when merging + $ git merge --no-ff branchName + + /////////////////////////////////////// + // mv + /////////////////////////////////////// + + Purpose: + Rename or move a file + + Examples: + // Renaming a file + $ git mv HelloWorld.c HelloNewWorld.c + + // Moving a file + $ git mv HelloWorld.c ./new/path/HelloWorld.c + + // Force rename or move + // "existingFile" already exists in the directory, will be overwritten + $ git mv -f myFile existingFile + + /////////////////////////////////////// + // pull + /////////////////////////////////////// + + Purpose: + Pulls from a repository and merges it with another branch. + + Examples: + // Update your local repo, by merging in new changes + // from the remote "origin" and "master" branch. + // git pull + $ git pull origin master + + /////////////////////////////////////// + // push + /////////////////////////////////////// + + Purpose: + Push, and merge changes from a branch to a remote & branch. + + Examples: + // Push, and merge changes from a local repo to a + // remote named "origin" and "master" branch. + // git push + // git push => implicitly defaults to => git push origin master + $ git push origin master + + /////////////////////////////////////// + // rebase (caution) + /////////////////////////////////////// + + Purpose: + Take all changes that were committed on one branch, and replay them onto another branch. + *Do not rebase commits that you have pushed to a public repo* + + Examples: + // Rebase experimentBranch onto master + // git rebase + $ git rebase master oldTest + + [Additional Reading.](http://git-scm.com/book/en/Git-Branching-Rebasing) + + /////////////////////////////////////// + // reset (caution) + /////////////////////////////////////// + + Purpose: + Reset the current HEAD to the specified state. This allows you to undo merges, + pulls, commits, adds, and more. It's a great command but also dangerous if you don't + know what you are doing. + + Examples: + // Reset the staging area, to match the latest commit (leaves dir unchanged) + $ git reset + + // Reset the staging area, to match the latest commit, and overwrite working dir + $ git reset --hard + + // Moves the current branch tip to the specified commit (leaves dir unchanged) + // all changes still exist in the directory. + $ git reset 31f2bb1 + + // Moves the current branch tip backward to the specified commit + // and makes the working dir match (deletes uncommited changes and all commits + // after the specified commit). + $ git reset --hard 31f2bb1 + + /////////////////////////////////////// + // rm + /////////////////////////////////////// + + Purpose: + The opposite of git add, git rm removes files from the current working tree. + + Example: + // remove HelloWorld.c + $ git rm HelloWorld.c + + // Remove a file from a nested dir + $ git rm /pather/to/the/file/HelloWorld.c + +``` + +## Further Information + +* [tryGit - A fun interactive way to learn Git.](http://try.github.io/levels/1/challenges/1) + +* [git-scm - Video Tutorials](http://git-scm.com/videos) + +* [git-scm - Documentation](http://git-scm.com/docs) + +* [Atlassian Git - Tutorials & Workflows](https://www.atlassian.com/git/) -- cgit v1.2.3 From ca4b0190958ee1b4a0394ac351c66c0f78bbda93 Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Mon, 15 Jul 2013 18:15:49 -0500 Subject: Update git.html.markdown Fixed some whitespace issues. --- git.html.markdown | 150 +++++++++++++++++++++++++++--------------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/git.html.markdown b/git.html.markdown index fd245e3c..ac3c26e7 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -23,20 +23,20 @@ of your source code. /////////////////////////////////////// /////////////////////////////////////// - // What is version control? - /////////////////////////////////////// + // What is version control? + /////////////////////////////////////// - Version control is a system that records changes to a file, or set of files over time. + Version control is a system that records changes to a file, or set of files, over time. /////////////////////////////////////// - // Centralized Versioning VS Distributed Versioning - /////////////////////////////////////// + // Centralized Versioning VS Distributed Versioning + /////////////////////////////////////// [Detailed Information & Images.](http://git-scm.com/book/en/Getting-Started-About-Version-Control) /////////////////////////////////////// - // Why Use Git? - /////////////////////////////////////// + // Why Use Git? + /////////////////////////////////////// * Can work offline. * Collaborating with others is easy! @@ -46,53 +46,53 @@ of your source code. * Git is flexible. /////////////////////////////////////// - // Repository - /////////////////////////////////////// + // Repository + /////////////////////////////////////// A set of files, directories, historical records, commits, and heads. Imagine it as a source code datastructure, with the attribute that each source code "element" gives you access to its revision history, among other things. A git repository is comprised of the .git directory & working tree. /////////////////////////////////////// - // .git Directory (component of repository) - /////////////////////////////////////// + // .git Directory (component of repository) + /////////////////////////////////////// The .git directory contains all the configurations, logs, branches, HEAD, and more. [Detailed List.](http://gitready.com/advanced/2009/03/23/whats-inside-your-git-directory.html) /////////////////////////////////////// - // Working Tree (component of repository) - /////////////////////////////////////// + // Working Tree (component of repository) + /////////////////////////////////////// This is basically the directories and files in your repository. It is often referred to as your working directory. /////////////////////////////////////// - // Index (component of .git) - /////////////////////////////////////// + // Index (component of .git) + /////////////////////////////////////// The Index is the staging area in git. It's basically layer that separates your working tree from the Git repository. This gives developers more power over what gets sent to the Git repository. /////////////////////////////////////// - // Commit - /////////////////////////////////////// + // Commit + /////////////////////////////////////// A git commit is a snapshot of a set of changes, or manipulations to your Working Tree. For example, if you added 5 files, and removed 2 others, you create a commit (or snapshot). This commit can then be pushed to other repositorys. /////////////////////////////////////// - // Branch - /////////////////////////////////////// + // Branch + /////////////////////////////////////// A branch is essentially a pointer that points to the last commit you made. As you commit this pointer will automatically update and point to the latest commit. /////////////////////////////////////// - // HEAD and head (component of .git) - /////////////////////////////////////// + // HEAD and head (component of .git) + /////////////////////////////////////// HEAD, is a pointer, to the current branch. A repository only has 1 active HEAD. head, is a pointer, that points to any commit. A repository can have any number of heads. @@ -102,9 +102,9 @@ of your source code. // Commands /////////////////////////////////////// - /////////////////////////////////////// - // init - /////////////////////////////////////// + /////////////////////////////////////// + // init + /////////////////////////////////////// Purpose: To create an empty Git repository. The Git repository's settings, stored information, @@ -113,9 +113,9 @@ of your source code. Examples: $ git init - /////////////////////////////////////// - // config - /////////////////////////////////////// + /////////////////////////////////////// + // config + /////////////////////////////////////// Purpose: To configure settings. Whether it be for the repository, the system itself, or global @@ -132,9 +132,9 @@ of your source code. [Learn More About git config.](http://git-scm.com/docs/git-config) - /////////////////////////////////////// - // help - /////////////////////////////////////// + /////////////////////////////////////// + // help + /////////////////////////////////////// Purpose: To give you quick access to an extremeled detailed guide of each command. Or to @@ -153,9 +153,9 @@ of your source code. $ git help commit $ git help init - /////////////////////////////////////// - // status - /////////////////////////////////////// + /////////////////////////////////////// + // status + /////////////////////////////////////// Purpose: To show differences between the index file (basically your working copy/repo) and the current @@ -168,9 +168,9 @@ of your source code. // To learn other "tid bits" about git status $ git help status - /////////////////////////////////////// - // add - /////////////////////////////////////// + /////////////////////////////////////// + // add + /////////////////////////////////////// Purpose: To add files to the current working tree/directory/repo. If you do not git add files to the @@ -186,9 +186,9 @@ of your source code. // Regular Expression support! $ git add ./*.java - /////////////////////////////////////// - // branch - /////////////////////////////////////// + /////////////////////////////////////// + // branch + /////////////////////////////////////// Purpose: Manage your branches. You can view, edit, create, delete branches using this command. @@ -210,9 +210,9 @@ of your source code. // edit a branch's description $ git branch myBranchName --edit-description - /////////////////////////////////////// - // checkout - /////////////////////////////////////// + /////////////////////////////////////// + // checkout + /////////////////////////////////////// Purpose: Updates all files in the working tree to match the version in the index, or specified tree. @@ -223,9 +223,9 @@ of your source code. // Checkout a specified branch $ git checkout -b branchName - /////////////////////////////////////// - // clone - /////////////////////////////////////// + /////////////////////////////////////// + // clone + /////////////////////////////////////// Purpose: Clones, or copys, an existing repository into a new directory. It almost adds @@ -236,9 +236,9 @@ of your source code. // Clone learnxinyminutes-docs $ git clone https://github.com/adambard/learnxinyminutes-docs.git - /////////////////////////////////////// - // commit - /////////////////////////////////////// + /////////////////////////////////////// + // commit + /////////////////////////////////////// Purpose: Stores the current contents of the index in a new "commit". This commit contains @@ -248,9 +248,9 @@ of your source code. // commit with a message $ git commit -m "Added multiplyNumbers() function to HelloWorld.c" - /////////////////////////////////////// - // grep - /////////////////////////////////////// + /////////////////////////////////////// + // grep + /////////////////////////////////////// Purpose: Allows you to quickly search a repository. @@ -273,9 +273,9 @@ of your source code. Google is your friend for more examples [Git Grep Ninja](http://travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja) - /////////////////////////////////////// - // log - /////////////////////////////////////// + /////////////////////////////////////// + // log + /////////////////////////////////////// Purpose: Display commits to the repository. @@ -290,9 +290,9 @@ of your source code. // Show merge commits only $ git log --merges - /////////////////////////////////////// - // merge - /////////////////////////////////////// + /////////////////////////////////////// + // merge + /////////////////////////////////////// Purpose: "Merge" in changes, from external commits, into the current branch. @@ -304,9 +304,9 @@ of your source code. // Always generate a merge commit when merging $ git merge --no-ff branchName - /////////////////////////////////////// - // mv - /////////////////////////////////////// + /////////////////////////////////////// + // mv + /////////////////////////////////////// Purpose: Rename or move a file @@ -322,9 +322,9 @@ of your source code. // "existingFile" already exists in the directory, will be overwritten $ git mv -f myFile existingFile - /////////////////////////////////////// - // pull - /////////////////////////////////////// + /////////////////////////////////////// + // pull + /////////////////////////////////////// Purpose: Pulls from a repository and merges it with another branch. @@ -335,9 +335,9 @@ of your source code. // git pull $ git pull origin master - /////////////////////////////////////// - // push - /////////////////////////////////////// + /////////////////////////////////////// + // push + /////////////////////////////////////// Purpose: Push, and merge changes from a branch to a remote & branch. @@ -349,9 +349,9 @@ of your source code. // git push => implicitly defaults to => git push origin master $ git push origin master - /////////////////////////////////////// - // rebase (caution) - /////////////////////////////////////// + /////////////////////////////////////// + // rebase (caution) + /////////////////////////////////////// Purpose: Take all changes that were committed on one branch, and replay them onto another branch. @@ -364,9 +364,9 @@ of your source code. [Additional Reading.](http://git-scm.com/book/en/Git-Branching-Rebasing) - /////////////////////////////////////// - // reset (caution) - /////////////////////////////////////// + /////////////////////////////////////// + // reset (caution) + /////////////////////////////////////// Purpose: Reset the current HEAD to the specified state. This allows you to undo merges, @@ -389,9 +389,9 @@ of your source code. // after the specified commit). $ git reset --hard 31f2bb1 - /////////////////////////////////////// - // rm - /////////////////////////////////////// + /////////////////////////////////////// + // rm + /////////////////////////////////////// Purpose: The opposite of git add, git rm removes files from the current working tree. -- cgit v1.2.3 From 62b9306f6c5a261349f99b703e94ac4830417f3b Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Tue, 16 Jul 2013 12:53:24 -0500 Subject: Added concept links & some minor text fixes. --- git.html.markdown | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/git.html.markdown b/git.html.markdown index ac3c26e7..d56f594a 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -68,7 +68,7 @@ of your source code. as your working directory. /////////////////////////////////////// - // Index (component of .git) + // Index (component of .git dir) /////////////////////////////////////// The Index is the staging area in git. It's basically layer that separates your working tree @@ -80,22 +80,29 @@ of your source code. /////////////////////////////////////// A git commit is a snapshot of a set of changes, or manipulations to your Working Tree. - For example, if you added 5 files, and removed 2 others, you create a commit (or snapshot). - This commit can then be pushed to other repositorys. + For example, if you added 5 files, and removed 2 others, these changes will be contained + in a commit (or snapshot). This commit, can then be pushed to other repositorys, or not! /////////////////////////////////////// // Branch /////////////////////////////////////// - A branch is essentially a pointer that points to the last commit you made. As you commit + A branch is essentially a pointer, that points to the last commit you made. As you commit this pointer will automatically update and point to the latest commit. /////////////////////////////////////// - // HEAD and head (component of .git) + // HEAD and head (component of .git dir) /////////////////////////////////////// - HEAD, is a pointer, to the current branch. A repository only has 1 active HEAD. + HEAD, is a pointer, that points to the current branch. A repository only has 1 *active* HEAD. head, is a pointer, that points to any commit. A repository can have any number of heads. + + /////////////////////////////////////// + // Conceptual Resources + /////////////////////////////////////// + + [Git For Computer Scientists](http://eagain.net/articles/git-for-computer-scientists/) + [Git For Designers](http://hoth.entp.com/output/git_for_designers.html) /////////////////////////////////////// @@ -414,3 +421,5 @@ of your source code. * [git-scm - Documentation](http://git-scm.com/docs) * [Atlassian Git - Tutorials & Workflows](https://www.atlassian.com/git/) + +* [SalesForce Cheat Sheet](https://na1.salesforce.com/help/doc/en/salesforce_git_developer_cheatsheet.pdf) -- cgit v1.2.3 From eef26a084197db553358bedcb3c7ffae4eaa826d Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Thu, 18 Jul 2013 11:49:27 -0500 Subject: some organization & clarification --- git.html.markdown | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/git.html.markdown b/git.html.markdown index d56f594a..696639fd 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -19,7 +19,7 @@ of your source code. ``` /////////////////////////////////////// -// Concepts +// Versioning Concepts /////////////////////////////////////// /////////////////////////////////////// @@ -45,11 +45,16 @@ of your source code. * Git is fast. * Git is flexible. +/////////////////////////////////////// +// Git Architecture +/////////////////////////////////////// + /////////////////////////////////////// // Repository /////////////////////////////////////// - A set of files, directories, historical records, commits, and heads. Imagine it as a source code datastructure, with the attribute that each source code "element" gives you access to its revision history, among other things. + A set of files, directories, historical records, commits, and heads. Imagine it as a source code datastructure, + with the attribute that each source code "element" gives you access to its revision history, among other things. A git repository is comprised of the .git directory & working tree. -- cgit v1.2.3 From 033c3bd770766d15a3b7c5ff7285748de866cbea Mon Sep 17 00:00:00 2001 From: Jake Prather Date: Thu, 18 Jul 2013 16:48:58 -0500 Subject: updates --- git.html.markdown | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git.html.markdown b/git.html.markdown index 696639fd..184ec14b 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -32,7 +32,11 @@ of your source code. // Centralized Versioning VS Distributed Versioning /////////////////////////////////////// - [Detailed Information & Images.](http://git-scm.com/book/en/Getting-Started-About-Version-Control) + * Centralized version control focuses on synchronizing, tracking, and backing up files. + * Distributed version control focuses on sharing changes. Every change has a unique id. + * Distributed systems have no defined structure. You could easily have a SVN style, centralized system, with git. + + [Additional Information](http://git-scm.com/book/en/Getting-Started-About-Version-Control) /////////////////////////////////////// // Why Use Git? -- cgit v1.2.3