Thứ Ba, 20 tháng 5, 2014

// // Leave a Comment

HƯớng dẫn sử dụng GIT trên Ubuntu

Local --> Server

B1: Tạo 1 repo dạng GIT Trên bitbucket:

#tạo 1 thư mục mới
thehai@thehai-Vostro-3550:~$ mkdir bai-tap-thu-3

#duy chuyển vào folder này
thehai@thehai-Vostro-3550:~$ cd bai-tap-thu-3/

#Tạo 1 repo rỗng dạng git
thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git init 
Initialized empty Git repository in /home/thehai/bai-tap-thu-3/.git/

(sau khi chạy git init sẽ xuất hiện thêm thư mục .git)
thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ ls -a
.  ..  .git  hello.txt

#Tạo 1 file bất kỳ trong folder này
thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ ls
hello.txt

thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git add hello.txt

thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git commit -m "loi xin chao dau tien"
[master (root-commit) 8b0ff25] loi xin chao dau tien
 1 file changed, 1 insertion(+)
 create mode 100644 hello.txt
thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git log
commit 8b0ff254a1eaa99640f9c003da65ecff7db1ff9e
Author: HaiLocal <hailocal@gmail.com>
Date:   Tue May 20 10:52:00 2014 +0700
    loi xin chao dau tien

thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git remote add origin https://hai991dk@bitbucket.org/hai991dk/bai-tap-thu-3.git

thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git push -u origin master
Password for 'https://hai991dk@bitbucket.org':
To https://hai991dk@bitbucket.org/hai991dk/bai-tap-thu-3.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
(dữ liệu đã đc đưa lên server )


Clone 1 repo mới trên Server về local:
thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ git clone https://hai991dk@bitbucket.org/hai991dk/bai-tap-thu-3.git
Cloning into 'bai-tap-thu-3'...
Password for 'https://hai991dk@bitbucket.org':
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.

thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ cat
bai-tap-thu-3/ .git/          hello.txt     
thehai@thehai-Vostro-3550:~/bai-tap-thu-3$ cd bai-tap-thu-3/
thehai@thehai-Vostro-3550:~/bai-tap-thu-3/bai-tap-thu-3$ ls
hello.txt

thehai@thehai-Vostro-3550:~/bai-tap-thu-3/bai-tap-thu-3$ cat hello.txt
xin chao moi nguoi
chao chao ccc

Tạo 1 thay đổi trên local, sau đó cập nhật lên server:

thehai@thehai-Vostro-3550:~/bai-tap-thu-3/bai-tap-thu-3$ git add hello.txt

thehai@thehai-Vostro-3550:~/bai-tap-thu-3/bai-tap-thu-3$ git commit -m "thanh nien nghiem tuc"
[master 3fa1ad0] thanh nien nghiem tuc
 1 file changed, 4 insertions(+), 1 deletion(-)

thehai@thehai-Vostro-3550:~/bai-tap-thu-3/bai-tap-thu-3$ git pull
Password for 'https://hai991dk@bitbucket.org':
Already up-to-date.

thehai@thehai-Vostro-3550:~/bai-tap-thu-3/bai-tap-thu-3$ git push
Password for 'https://hai991dk@bitbucket.org':
To https://hai991dk@bitbucket.org/hai991dk/bai-tap-thu-3.git
   00a2dde..3fa1ad0  master -> master

0 nhận xét:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.