Github and Website Workshop/git summary: Difference between revisions
Content added Content deleted
imported>Auria No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 4: | Line 4: | ||
*<tt>git init</tt>: tell git you want to use it in this folder (creates a repository) |
*<tt>git init</tt>: tell git you want to use it in this folder (creates a repository) |
||
*<tt>git status</tt> |
*<tt>git status</tt>: see what the current state of our project is |
||
** Tip: It's healthy to run git status often. Sometimes things change and you don't notice it. |
** Tip: It's healthy to run git status often. Sometimes things change and you don't notice it. |
||
*<tt>git add ''filename''</tt>: Tell git to stage this file |
*<tt>git add ''filename''</tt>: Tell git to stage this file |
||
*<tt>git add -A . |
*<tt>git add -A .</tt>: add all - where the dot stands for the current directory, so everything in and beneath it is added. The -a stands for all and ensures even file deletions are included |
||
*<tt>git reset ''filename'' |
*<tt>git reset ''filename''</tt>: removes a file from the staging area |
||
*<tt>git commit -m "''commit message''"</tt>: commit the staged files (saves a snapshot) |
|||
⚫ | |||
⚫ | |||
** Tip: use <tt>git log --summary</tt> to see more information for each commit. You can see where new files were added for the first time or where files were deleted. It's a good overview of the project. |
** Tip: use <tt>git log --summary</tt> to see more information for each commit. You can see where new files were added for the first time or where files were deleted. It's a good overview of the project. |
||
*<tt>git remote add ''alias url'' |
*<tt>git remote add ''alias url''</tt>: add a new remote repository of your project to your local computer files |
||
*<tt>git push ''to from''</tt>: tells Git where to put our commits |
*<tt>git push ''to from''</tt>: tells Git where to put our commits |
||
** If you put -u before ''to'', it tells Git to remember the parameters, so that next time we can simply run <tt>git push</tt> and Git will know what to do. |
** If you put -u before ''to'', it tells Git to remember the parameters, so that next time we can simply run <tt>git push</tt> and Git will know what to do. |
||
*<tt>git pull ''from to'' |
*<tt>git pull ''from to''</tt>: check for changes on our GitHub repository and pull down new changes |
||
*<tt>git diff ''change''</tt> |
*<tt>git diff ''change''</tt>: shows the difference between the current state of the files and previous commit |
||
** if you don't specify a ''change'', the default is HEAD which by default holds most recent commit, so <tt>git diff</tt> shows difference from last commit |
** if you don't specify a ''change'', the default is HEAD which by default holds most recent commit, so <tt>git diff</tt> shows difference from last commit |
||
** <tt>git diff staged</tt> lets you see the changes you just staged |
** <tt>git diff staged</tt> lets you see the changes you just staged |
||
*<tt>git reset ''file''</tt> |
*<tt>git reset ''file''</tt>: unstages the file |
||
*<tt>git checkout |
*<tt>git checkout ''file''</tt>: get rid of all the changes since the last commit for the file |
||
*<tt>git clone ''url'' |
*<tt>git clone ''url''</tt>: copy a git repository so you can add to it |
||
=== Terms === |
=== Terms === |
Latest revision as of 03:15, 23 February 2015
This is a summary of the git commands and concepts discussed at the Github and Website Workshop
Commands
- git init: tell git you want to use it in this folder (creates a repository)
- git status: see what the current state of our project is
- Tip: It's healthy to run git status often. Sometimes things change and you don't notice it.
- git add filename: Tell git to stage this file
- git add -A .: add all - where the dot stands for the current directory, so everything in and beneath it is added. The -a stands for all and ensures even file deletions are included
- git reset filename: removes a file from the staging area
- git commit -m "commit message": commit the staged files (saves a snapshot)
- git log: Git's journal - remembers the changes we've committed in the order we committed them
- Tip: use git log --summary to see more information for each commit. You can see where new files were added for the first time or where files were deleted. It's a good overview of the project.
- git remote add alias url: add a new remote repository of your project to your local computer files
- git push to from: tells Git where to put our commits
- If you put -u before to, it tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.
- git pull from to: check for changes on our GitHub repository and pull down new changes
- git diff change: shows the difference between the current state of the files and previous commit
- if you don't specify a change, the default is HEAD which by default holds most recent commit, so git diff shows difference from last commit
- git diff staged lets you see the changes you just staged
- git reset file: unstages the file
- git checkout file: get rid of all the changes since the last commit for the file
- git clone url: copy a git repository so you can add to it
Terms
- Directory: A folder used for storing multiple files.
- Repository: A directory where git has been initialized to start version controlling your files.
- Staging Area: A place where we can group files together before we "commit" them to Git.
- Commit: A "commit" is a snapshot of our repository. This way if we ever need to look back at the changes we've made (or if someone else does), we will see a nice timeline of all changes.
- Staged: Files are ready to be committed
- Unstaged: Files with changes that have not been prepared to be committed
- Untracked: Files aren't tracked by git yet. This usually indicates a newly created file
- Deleted: File has been deleted and is waiting to be removed from git
- Remote repositories: versions of your project that are hosted on the Internet or network somewhere