git - the basics
-
Upload
arnelle-balane -
Category
Technology
-
view
104 -
download
0
Transcript of git - the basics
parts of a git repository
working directory
staging area (index)
git directory(HEAD)
stage commit
checkout
getting a git repository
git init
create one
git clone /path/to/repository
copy an existing repository
timeline
HEADmaster
timeline
HEADmaster
tracking files / staging files
git add [filename]
git add [filename1] [filename2] [filename3]
git add . or git add *
untracked staged
modified staged
git work flow
create / delete / modify files
stage files
commit changes
[repeat]
git commit –am “commit message”
removing files
git rm [filename]
git rm [filename1] [filename2] [filename3]
removes the file from the staging area and the working directory
undoing things
git checkout -- [filename]
discarding changes
modified unmodified
git reset HEAD [filename]
unstaging files
git reset HEAD
staged modified
undoing things
git commit --amend
changing the last commit
git reset --soft HEAD
undoing the last commit
unmodified staged
git reset --hard HEAD discard all changes in last commit
viewing changes
git diff
unstaged changes
git show [commit hash]
changes done in a commit
git diff --cached
staged changes
viewing commit history
git log
git log --oneline
git log --graph
git log --since=“2013-12-01”
git log --author=“Lorem Ipsum”
git log --until=“2013-12-01”
creating a branch
git branch [branch name] git checkout [branch-name]
switch to the new branch
timeline
HEAD
[branch name]
master timeline
HEAD
[branch name]
master
git checkout –b [branch name]
merging branches
git checkout [branch to merge into]
switch to the branch you want to merge into
git merge [branch to merge from]
perform merge
deleting a branch
git checkout [some other branch]
switch to a branch other than the one to be deleted
git branch –d [branch name]
delete branch
setting up for Github
sign up for a Github account
generate SSH key (if your machine currently doesn’t have one)
add your SSH key to your Github account
two repositories
local repository- working directory- staging area- git directory
remote repository
- git directory
managing remotes
git remote add [remote name] [remote URL]
creating a new remote
git remote rm [remote name]
deleting a remote
data transfer to/from a remote
git push [remote name] [remote branch name]
sending data to a remote
git pull [remote name] [remote branch name]
getting data from a remote