Please enable JavaScript.
Coggle requires JavaScript to display documents.
How to use Git and Github (Git (commands (Git log (Git log --stat (show…
How to use Git and Github
Git
is a version control system
easier to collaborate with other people
more effecient
used by big technololy companies
like undo button
compare diffrent versions
restore previous version n
save versions of files at different point of time
recommend app have version control system
sublime text
https://www.udacity.com/wiki/ud775/sublime
ggdoc
dropbox
wikipedia
other widely-adopted system
CVS: concurrent version system
SVN: Subversion, some extended
Mercury (Hg)
use linux command line
2005 by Linux Torvalds
some defines
commits
representing a version at one point in time
should take once we have logical changed
are user-created checkpoints
a snapshot of a repository
README
contain discriptions
repository
a collection of files
contain relative files
staging
collection of files will be snap in one commit
branches
are label of commits
master
the main branch
branch which has asteroid mark will be update when make changes
commands
Git log
id, author, date change, serial number, discriptions
better than FC or diff
Git log --stat
show files affected at the same repository
press Q to exit
Git log --graph (--oneline)
to draw out the graph of branches
Git diff
Git diff id0fOld idOfNew
has color easier to check
red for deletion green for insertion
to see differences between 2 version like diff
compare working directory vs staging area
Git diff --staged
compare staging area with repository
Git clone URL
to copy all history of repository to pc from URL
it crate a coppy of repository at current directory
if forked, it automatically add remote as origin
Git config ....
Git config --global color.ui auto
and other config command...
apply color for all repositories' log
at first have to set account
Git config --global user.mail "your email"
Git config --global user.name "your username on git"
Git config --global --autocrlf true
to avoid conflict cause by newline letters \n and \r\n
Git checkout
Git checkout id
to reverse to id's version
Git checkout branch'sname
switch branch to branch'sname
tab to complete command
Git add file
add file to staging collection
Git status
check commit status
Git init
add an empty repository at current directory
Git commit
#
Git branch
show current branches
Git branch nameabc
create branch called nameabc
Git branch -b nameabc
create and switch to branch called nameabc
Git branch -d name
delete label of branch
it won't del commits at that branch
Git merge branch1
merge branch1 into current checkout
Git merge branch1 branch2
merge branch1 vs branch2 vs current checkout
Git merge --abort
reverse to state before conflict
after merge, commits will be sort by time line
if merge cause a conflic, the conflict file will have all version and let you decide how to solve
Git show id
to compare id commit with the parent commit
Work on my own computer
GitHub
a code collaboration web platform
to share your git with other people
reflect file
create repository on github
copy link
move to folder want to reflect
git remote add name <link>
git remote -v
to check
define
forking
to clone someone repository on github to your git hub acc
git pull remotebrench1 branch1
to update to remote1/branch1
git push remote1 branch1
to upload local version to remote1/branch1
git fetch
to download all branch without merging to avoid conflict
3 lessions
advantages of version control and install git
lean using git
practicing, sharing and collaborating with other using Github
tools compare code by commandline
win
FC (file compare)
cd to files
command> FC file1 file2
mac/linux
Diff (difference)
cd to files
diff -u file1 file2
setup cmd log memory
left click on cmd icon at top left corner
properties
set buffer number
repository
data files...
.git
hiden from explorer
contain data for git service
config
objects
create ssh connetion
check existed key
ls -al ~/.ssh
generate new key
ssh-keygen -t rsa -b 4096 -C "label"
enter file name
enter password
ssh-keygen -p
to change password
add key to agent
eval $(ssh-agent -s)
to start agent process
ssh-add ~/.ssh/<keyfile>
add key to github acc
clip < ~/.ssh/<keyfile.pub>
open github page
seting
ssh and GPG key
new ssh key
enter label as computer name
enter public key from clip board (paste)
to remember github pass and acc
git config --global credential.helper wincred
to clone by HTTPS
create file ~/.ssh/config
Host github.com \n\t Hostname ssh.github.com \n Port 443