Sie sind auf Seite 1von 8

Git is distributed versions control system, that log every working history that push to

repository (area for store).


1. Install Git in Ubuntu
install rvm, on terminal run
sudo apt-get install git
!fter finish install git, you can check if installation is working with
git --version
"hat will result git version 1.#.1 , that means git version in local is 1.#.1.
!fter success install git now we need configure the git username and email, on terminal
run
git config --global user.name <your_full_name>
git config --global user.email <your_email_address>
$or e%ample
git config --global user.name mohamad_dwikuntobayu
git config --global user.email dwikuntobayu@gmail.com
$or check your configuration, on terminal run
git config list
"hat will result
user.name&mohamad'dwikuntobayu
user.email&mdwikuntobayu(gmail.com
that configuration is saved in ~/.gitconfig.
). *ocal Implementation
after success install and configure the git now we will using git in our local, let create the
blang folder in home directory
mkdir learn_git_local
+ow move to that directory
cd learn_git_local
!fter we inside the folder now we need set ,learn'git'local, as our local repository, on
terminal run
git init
"hat will result
Initiali-ed empty Git repository in .home.username.Gawe.learn'git'local..git.
then check current state repository, run
git status
"hat will result
/n branch master
Initial commit
nothing to commit (create.copy files and use 0git add0 to track)
it means repository in branch ,master,, and nothing to be commit(save our working to local
repository), now add new file
touch learn_git.txt
then check current state repository, run
git status
"hat will result
/n branch master
Initial commit
Untracked files
(use 0git add 1file2...0 to include in what will be committed)
learn'git.t%t
nothing added to commit but untracked files present (use 0git add0 to track)
it means in local working folder detect new file that need add to our repository, git will give
suggestion for what action that we gonna do, from that status git suggest for add new file
learn_git.txt, run
git add git.txt
"hen if you check status repository, run
git status
"hat will result
/n branch master
Initial commit
3hanges to be committed
(use 0git rm 44cached 1file2...0 to unstage)
new file learn'git.t%t
it means file learn_git.txt has add to inde% of working tree and prepare for ne%t commit, so
every change from this file will logged. +ow try add content to learn_git.txt, run
gedit learn_git.txt
!dd te%t
*earn git
in local repository
save the file and close the gedit. +ow if you check
git status
"hat will result
/n branch master
Initial commit
3hanges to be committed
(use 0git rm 44cached 1file2...0 to unstage)
new file learn'git.t%t
3hanges not staged for commit
(use 0git add 1file2...0 to update what will be committed)
(use 0git checkout 44 1file2...0 to discard changes in working directory)
modified learn'git.t%t
that means file learn_git.txt has changes, if you notice there git suggestion for git add or git
checkout, if you use git checkout learn_git.txt, that will remove all changes back to first add
that file or when the last commit. $or see what that has add to that file use
git diff learn_git.txt
"hat will result
diff 44git a.learn'git.t%t b.learn'git.t%t
inde% e5#de)#..e156#7a 188577
444 a.learn'git.t%t
999 b.learn'git.t%t
(( 48,8 91,) ((
9*earn git
9in local repository
if you see (( 48,8 91,) ((, it means in the file has add from line 1 until line ). !nd
9*earn git 9in local repository, that means in the file has add te%t :*earn git in local
repository;. <ere we will use git add, run
git add learn_git.txt
"hen if you check
git status
"hat will result
/n branch master
Initial commit
3hanges to be committed
(use 0git rm 44cached 1file2...0 to unstage)
new file learn'git.t%t
now we need commit our changes, run
git commit learn_git.txt -m First Commit
"hat command means we commit our changes with messages :$irst 3ommit;. +ow if you
check
git status
"hat will result
/n branch master
nothing to commit, working directory clean
it means in branch master nothing changes. +ow we want see logs of commit for the last
created
git log -1
"hat will result
commit 6=>1=5a66cecace8)b#cd71?777dd58=7#6)b5e8
!uthor mohamad'dwikuntobayu 1dwikunto.bayu(kiranatama.com2
@ate "hu Aep 1= 171??5 )817 98688
!fter success commit for first time, we want work on new branch so the base proBect not
changed. *et,s create new branch, run
git branch development_1
C if you want delete branch use git branch -d development_1
3heck the all branch that e%ist for repository, run
git branch
"hat will result
development'1
C master
the mark ,C, it means the repository in branch master, if you want move to branch
,development_1', run
git checkout development_1
"hat will result Awitched to branch ,development'1,
+ow if check the current branch
git branch
"hat will result
C development'1
master
it means the repository has move to branch ,development_1'.
C git checkout, can be use for remove change in working file or switch between branch.
?. Demote Aerver Implementation
"here many remote server for git in market like github.com, bitbucket.org. "he difference
between those is github cannot create private repository for free account that means
github focus on open source proBect, whereas bitbucket allow create private repository for
free account, that means bitbucket it more focus for enterprise.
?.1. Generate AA< key
AA< is a cryptographic network protocol for secure data communication, remote
command4line login, remote command e%ecution, and other secure network services
between two networked computers.
$or create new ssh key in ubuntu, on terminal run
ssh4keygen 4t rsa 43 1your(email.adreess2
$or e%ample
cd ~
ssh4keygen 4t rsa 43 0dwikunto.bayu(kiranatama.com0
!fter run that command you will asking for destination, and passphrase.
4 $or destination let it default put in E..ssh
4 passphrase is your choice, let it blank.
!fter success it will generate
4 .ssh.
44 id'rsa
44 id'rsa.pub
44 known'hosts
,id_rsa.pub, file contain public key, that will use for communication between remote server
and local.
?.). 3reate Github account
<ere we will use github as remote repository, first create account in
https://github.com/join
!fter success create new new account, now we need add AA< Fey to github, so
communication between local repository and remote server repository in github can
establish, goto https://github.com/settings/ssh, click button :Add SS ke!;, that will show
input form
4 in input "itle, insert your email address.
4 in input Fey, insert your public key from ,.ssh.id'rsa.pub,. $or e%ample on terminal run
cat E..ssh.id'rsa.pub
That will result :
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQCitja8j9ib!"#$!h%A&'&B()N*l+,Q)yl%-l.E-#/2cC,1,D012++a3rt4b5064D8bA287!3D
,(y8*)wj9:;1-)BE15tB''b<=D3DsT2l1%buNy8B5Nzl',c3:a,E5b9.j'0!1>A?@c2&j1C*5a58DAb3tA"ss#aT26hBa.2?:j(/*j4$:h"18la
1at+y3AyD>eNa@,yN/yh:8z=1cetB?=;A=<("35"1%iChj/9w(3BE=!TN!?D/64"22B%2A38">2;&13+3<r6E30B$"314*8.s60.cA8D*
h3i$aNT?:9%c3h.1A<B88B+Nbb-b+7ha-D&2'll'C#bCh ;wi,u4t#DbayuE,ira4ataaDc#
copy that public key to insert field, so it will look like
click button :!dd key;.
+ow create new repository in
https://github.com/new
$ill Depository +ame same with name in *ocal Depository ,learn_git_local,, choose public
so everyone can see. !fter you click button ,3reate repository,, that will redirect to
that is description how to setting local repository so you can sent all commit in local into
remote server github. "his is e%ample to setup in local, open console
cd learn'git'local
!fter move inside ,learn'git'local,, run
git remote add origin git@github.com:dwikuntobayu/learn_git_local.git
Cif you want modify remote repository use git remote set4url origin 1link'to'remote2
e%ample git remote set4url origin https..dwikuntobayu(bitbucket.org.dwikuntobayu.learn'git'local.git
"hat git command is for setup remote repository to github, if you want see detail can be
found in file ,learn_git_local/.git/config,. ,/rigin, is default name repository github.
?.?. Implement Github
!fter success setup configuration now we need push(send local repository to github) the
work result. /n terminal, and make sure you in ,learn_git_local, run
git push 4u origin master
If you setup passphrase when generate ssh key, when you push it will asking passphrase.
"hen if success it will show message
3ounting obBects >, done.
Griting obBects 188H (?.?), ?8? bytes I 8 bytes.s, done.
"otal ? (delta 8), reused 8 (delta 8)
"o git(github.comdwikuntobayu.learn'git'local.git
6=>1=5a..)#e8?=5 master 42 master
now if you access https://github.com/your_user_name/learn_git_local/commits/master , that will
show list commit in our local that logs date, author, then the detail changes.
+e%t if you want push to github again use
git push
Cif ,git push, not work use this ,git push origin master,
"hat because you use ,4u, (this command allow you not include origin and master) when
first time push to github
after success push our working to github, then other developers has modify our work and
push to github, that means our local work need to be updated with changes from remote
repository, inside ,learn_git_local, run
git pull origin master
"he ,git pull, will success run when in our local repository the modified field was commit, if
not git will give suggestion what must gonna do before pull.
Jake sure every commit that has push to remote server is never rollback, because it will
result bad behavior, so make sure your work was tested or create new branch for backup
your work before push to remote server.
Jake sure you not modify the same file with other members, because it will cause
conflict(redudancy in repository that will cause confusion git engine for choose the which
one the valid changes), for prevent this you must pull first before push to git server, but if
conflict still happens you must manually modify the changes and choose the updated or
both change that will commit.
for complete resources http://git-scm.com/docs

Das könnte Ihnen auch gefallen