1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-06 06:47:54 +02:00

Fixed stuff

This commit is contained in:
Adam
2013-07-21 16:47:55 -07:00
parent c914885188
commit 1466127aa3
3 changed files with 347 additions and 409 deletions

View File

@@ -1,8 +1,8 @@
--- ---
category: tool
language: git tool: git
contributors: contributors:
- ["Jake Prather", "http://github.com/JakeHP"] - ["Jake Prather", "http:#github.com/JakeHP"]
filename: LearnGit.txt filename: LearnGit.txt
--- ---
@@ -16,31 +16,21 @@ manage your source code.
In layman's terms, it's a way of managing, and keeping a detailed historical record, In layman's terms, it's a way of managing, and keeping a detailed historical record,
of your source code. of your source code.
``` ## Versioning Concepts
/////////////////////////////////////// ### What is version control?
// Versioning Concepts
///////////////////////////////////////
///////////////////////////////////////
// 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
///////////////////////////////////////
* Centralized version control focuses on synchronizing, tracking, and backing up files. * 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 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. * 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) [Additional Information](http:#git-scm.com/book/en/Getting-Started-About-Version-Control)
/////////////////////////////////////// ### Why Use Git?
// Why Use Git?
///////////////////////////////////////
* Can work offline. * Can work offline.
* Collaborating with others is easy! * Collaborating with others is easy!
@@ -49,386 +39,334 @@ of your source code.
* Git is fast. * Git is fast.
* Git is flexible. * Git is flexible.
/////////////////////////////////////// ## Git Architecture
// Git Architecture
///////////////////////////////////////
///////////////////////////////////////
// Repository ### Repository
///////////////////////////////////////
A set of files, directories, historical records, commits, and heads. Imagine it as a source code datastructure, 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. 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. 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. 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) [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 This is basically the directories and files in your repository. It is often referred to
as your working directory. as your working directory.
/////////////////////////////////////// ### Index (component of .git dir)
// Index (component of .git dir)
///////////////////////////////////////
The Index is the staging area in git. It's basically layer that separates your working tree 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 from the Git repository. This gives developers more power over what gets sent to the Git
repository. repository.
/////////////////////////////////////// ### Commit
// Commit
///////////////////////////////////////
A git commit is a snapshot of a set of changes, or manipulations to your Working Tree. 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, these changes will be contained 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! in a commit (or snapshot). This commit, can then be pushed to other repositorys, or not!
/////////////////////////////////////// ### Branch
// 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. this pointer will automatically update and point to the latest commit.
/////////////////////////////////////// ### HEAD and head (component of .git dir)
// HEAD and head (component of .git dir)
///////////////////////////////////////
HEAD, is a pointer, that points 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. head, is a pointer, that points to any commit. A repository can have any number of heads.
/////////////////////////////////////// ### Conceptual Resources
// Conceptual Resources
///////////////////////////////////////
[Git For Computer Scientists](http://eagain.net/articles/git-for-computer-scientists/) [Git For Computer Scientists](http:#eagain.net/articles/git-for-computer-scientists/)
[Git For Designers](http://hoth.entp.com/output/git_for_designers.html) [Git For Designers](http:#hoth.entp.com/output/git_for_designers.html)
/////////////////////////////////////// ## Commands
// Commands
///////////////////////////////////////
///////////////////////////////////////
// init
///////////////////////////////////////
Purpose: ### init
To create an empty Git repository. The Git repository's settings, stored information,
Create an empty Git repository. The Git repository's settings, stored information,
and more is stored in a directory, or folder named, ".git". and more is stored in a directory, or folder named, ".git".
Examples: ```bash
$ git init $ git init
```
/////////////////////////////////////// ### config
// config
///////////////////////////////////////
Purpose:
To configure settings. Whether it be for the repository, the system itself, or global To configure settings. Whether it be for the repository, the system itself, or global
configurations. configurations.
Examples:
// Print & Set Some Basic Config Variables (Global) ```bash
# Print & Set Some Basic Config Variables (Global)
$ git config --global user.email $ git config --global user.email
$ git config --global user.name $ git config --global user.name
$ git config --global user.email "MyEmail@Zoho.com" $ git config --global user.email "MyEmail@Zoho.com"
$ git config --global user.name "My Name" $ git config --global user.name "My Name"
```
[Learn More About git config.](http://git-scm.com/docs/git-config) [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 To give you quick access to an extremeled detailed guide of each command. Or to
just give you a quick reminder of some semantics. just give you a quick reminder of some semantics.
Examples: ```bash
// Quickly check available commands # Quickly check available commands
$ git help $ git help
// Check all available commands # Check all available commands
$ git help -a $ git help -a
// Command specific help - user manual # Command specific help - user manual
// git help <command_here> # git help <command_here>
$ git help add $ git help add
$ git help commit $ git help commit
$ git help init $ git help init
```
/////////////////////////////////////// ### status
// status
///////////////////////////////////////
Purpose:
To show differences between the index file (basically your working copy/repo) and the current To show differences between the index file (basically your working copy/repo) and the current
HEAD commit. HEAD commit.
Examples:
// Will display the branch, untracked files, changes and other differences ```bash
# Will display the branch, untracked files, changes and other differences
$ git status $ git status
// To learn other "tid bits" about git status # To learn other "tid bits" about git status
$ git help status $ git help status
```
/////////////////////////////////////// ### add
// add
///////////////////////////////////////
Purpose: To add files to the current working tree/directory/repo. If you do not git add new files to the
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! working tree/directory they will not be included in commits!
Exmaples: ```bash
// add a file in your current working directory # add a file in your current working directory
$ git add HelloWorld.java $ git add HelloWorld.java
// add a file in a nested dir # add a file in a nested dir
$ git add /path/to/file/HelloWorld.c $ git add /path/to/file/HelloWorld.c
// Regular Expression support! # Regular Expression support!
$ git add ./*.java $ git add ./*.java
```
/////////////////////////////////////// ### branch
// branch
///////////////////////////////////////
Purpose:
Manage your branches. You can view, edit, create, delete branches using this command. Manage your branches. You can view, edit, create, delete branches using this command.
Examples: ```bash
// list existing branches & remotes # list existing branches & remotes
$ git branch -a $ git branch -a
// create a new branch # create a new branch
$ git branch myNewBranch $ git branch myNewBranch
// delete a branch # delete a branch
$ git branch -d myBranch $ git branch -d myBranch
// rename a branch # rename a branch
// git branch -m <oldname> <newname> # git branch -m <oldname> <newname>
$ git branch -m myBranchName myNewBranchName $ git branch -m myBranchName myNewBranchName
// edit a branch's description # edit a branch's description
$ git branch myBranchName --edit-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. Updates all files in the working tree to match the version in the index, or specified tree.
Examples: ```bash
// Checkout a repo - defaults to master branch # Checkout a repo - defaults to master branch
$ git checkout $ git checkout
// Checkout a specified branch # Checkout a specified branch
$ git checkout -b branchName $ git checkout -b branchName
```
/////////////////////////////////////// ### clone
// clone
///////////////////////////////////////
Purpose:
Clones, or copys, an existing repository into a new directory. It almost adds 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 remote-tracking branches for each branch in the cloned repo. (which allows you to push
to a remote branch) to a remote branch)
Examples: ```bash
// Clone learnxinyminutes-docs # Clone learnxinyminutes-docs
$ git clone https://github.com/adambard/learnxinyminutes-docs.git $ 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 Stores the current contents of the index in a new "commit". This commit contains
the changes made and a message created by the user. the changes made and a message created by the user.
Examples: ```bash
// commit with a message # commit with a message
$ git commit -m "Added multiplyNumbers() function to HelloWorld.c" $ git commit -m "Added multiplyNumbers() function to HelloWorld.c"
```
/////////////////////////////////////// ### grep
// grep
///////////////////////////////////////
Purpose:
Allows you to quickly search a repository. Allows you to quickly search a repository.
Optional Configurations: Optional Configurations:
// Thanks to Travis Jeffery for these
// Set line numbers to be shown in grep search results ```bash
# Thanks to Travis Jeffery for these
# Set line numbers to be shown in grep search results
$ git config --global grep.lineNumber true $ git config --global grep.lineNumber true
// Make search results more readable, including grouping # Make search results more readable, including grouping
$ git config --global alias.g "grep --break --heading --line-number" $ git config --global alias.g "grep --break --heading --line-number"
```
Examples: ```bash
// Search for "variableName" in all java files # Search for "variableName" in all java files
$ git grep 'variableName' -- '*.java' $ git grep 'variableName' -- '*.java'
// Search for a line that contains "arrayListName" and, "add" or "remove" # Search for a line that contains "arrayListName" and, "add" or "remove"
$ git grep -e 'arrayListName' --and \( -e add -e remove \) $ git grep -e 'arrayListName' --and \( -e add -e remove \)
```
Google is your friend for more examples Google is your friend for more examples
[Git Grep Ninja](http://travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja) [Git Grep Ninja](http:#travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja)
/////////////////////////////////////// ### log
// log
///////////////////////////////////////
Purpose:
Display commits to the repository. Display commits to the repository.
Examples: ```bash
// Show all commits # Show all commits
$ git log $ git log
// Show X number of commits # Show X number of commits
$ git log -n 10 $ git log -n 10
// Show merge commits only # Show merge commits only
$ git log --merges $ git log --merges
```
/////////////////////////////////////// ### merge
// merge
///////////////////////////////////////
Purpose:
"Merge" in changes, from external commits, into the current branch. "Merge" in changes, from external commits, into the current branch.
Examples: ```bash
// Merge the specified branch into the current. # Merge the specified branch into the current.
$ git merge branchName $ git merge branchName
// Always generate a merge commit when merging # Always generate a merge commit when merging
$ git merge --no-ff branchName $ git merge --no-ff branchName
```
/////////////////////////////////////// ### mv
// mv
///////////////////////////////////////
Purpose:
Rename or move a file Rename or move a file
Examples: ```bash
// Renaming a file # Renaming a file
$ git mv HelloWorld.c HelloNewWorld.c $ git mv HelloWorld.c HelloNewWorld.c
// Moving a file # Moving a file
$ git mv HelloWorld.c ./new/path/HelloWorld.c $ git mv HelloWorld.c ./new/path/HelloWorld.c
// Force rename or move # Force rename or move
// "existingFile" already exists in the directory, will be overwritten # "existingFile" already exists in the directory, will be overwritten
$ git mv -f myFile existingFile $ git mv -f myFile existingFile
```
/////////////////////////////////////// ### pull
// pull
///////////////////////////////////////
Purpose:
Pulls from a repository and merges it with another branch. Pulls from a repository and merges it with another branch.
Examples: ```bash
// Update your local repo, by merging in new changes # Update your local repo, by merging in new changes
// from the remote "origin" and "master" branch. # from the remote "origin" and "master" branch.
// git pull <remote> <branch> # git pull <remote> <branch>
$ git pull origin master $ git pull origin master
```
/////////////////////////////////////// ### push
// push
///////////////////////////////////////
Purpose:
Push, and merge changes from a branch to a remote & branch. Push, and merge changes from a branch to a remote & branch.
Examples: ```bash
// Push, and merge changes from a local repo to a # Push, and merge changes from a local repo to a
// remote named "origin" and "master" branch. # remote named "origin" and "master" branch.
// git push <remote> <branch> # git push <remote> <branch>
// git push => implicitly defaults to => git push origin master # git push => implicitly defaults to => git push origin master
$ 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. 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* *Do not rebase commits that you have pushed to a public repo*
Examples: ```bash
// Rebase experimentBranch onto master # Rebase experimentBranch onto master
// git rebase <basebranch> <topicbranch> # git rebase <basebranch> <topicbranch>
$ git rebase master oldTest $ git rebase master oldTest
```
[Additional Reading.](http://git-scm.com/book/en/Git-Branching-Rebasing) [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, 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 pulls, commits, adds, and more. It's a great command but also dangerous if you don't
know what you are doing. know what you are doing.
Examples: ```bash
// Reset the staging area, to match the latest commit (leaves dir unchanged) # Reset the staging area, to match the latest commit (leaves dir unchanged)
$ git reset $ git reset
// Reset the staging area, to match the latest commit, and overwrite working dir # Reset the staging area, to match the latest commit, and overwrite working dir
$ git reset --hard $ git reset --hard
// Moves the current branch tip to the specified commit (leaves dir unchanged) # Moves the current branch tip to the specified commit (leaves dir unchanged)
// all changes still exist in the directory. # all changes still exist in the directory.
$ git reset 31f2bb1 $ git reset 31f2bb1
// Moves the current branch tip backward to the specified commit # Moves the current branch tip backward to the specified commit
// and makes the working dir match (deletes uncommited changes and all commits # and makes the working dir match (deletes uncommited changes and all commits
// after the specified commit). # after the specified commit).
$ git reset --hard 31f2bb1 $ git reset --hard 31f2bb1
```
/////////////////////////////////////// ### rm
// rm
///////////////////////////////////////
Purpose:
The opposite of git add, git rm removes files from the current working tree. The opposite of git add, git rm removes files from the current working tree.
Example: ```bash
// remove HelloWorld.c # remove HelloWorld.c
$ git rm HelloWorld.c $ git rm HelloWorld.c
// Remove a file from a nested dir # Remove a file from a nested dir
$ git rm /pather/to/the/file/HelloWorld.c $ git rm /pather/to/the/file/HelloWorld.c
``` ```
## Further Information ## Further Information
* [tryGit - A fun interactive way to learn Git.](http://try.github.io/levels/1/challenges/1) * [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 - Video Tutorials](http:#git-scm.com/videos)
* [git-scm - Documentation](http://git-scm.com/docs) * [git-scm - Documentation](http:#git-scm.com/docs)
* [Atlassian Git - Tutorials & Workflows](https://www.atlassian.com/git/) * [Atlassian Git - Tutorials & Workflows](https:#www.atlassian.com/git/)
* [SalesForce Cheat Sheet](https://na1.salesforce.com/help/doc/en/salesforce_git_developer_cheatsheet.pdf) * [SalesForce Cheat Sheet](https:#na1.salesforce.com/help/doc/en/salesforce_git_developer_cheatsheet.pdf)

View File

@@ -343,7 +343,7 @@ class Bicycle {
speed -= decrement; speed -= decrement;
} }
public void setName(int newName) { public void setName(String newName) {
name = newName; name = newName;
} }

View File

@@ -12,7 +12,7 @@ Racket is a general purpose, multi-paradigm programming language in the Lisp/Sch
Feedback is appreciated! You can reach me at [@th3rac25](http://twitter.com/th3rac25) or th3rac25 [at] [google's email service] Feedback is appreciated! You can reach me at [@th3rac25](http://twitter.com/th3rac25) or th3rac25 [at] [google's email service]
```scheme ```racket
#lang racket ; defines the language we are using #lang racket ; defines the language we are using
;;; Comments ;;; Comments