- git init
- git status (để xem có file untracked nào không)
- git add octocat.txt (để add file vào một staging area mà được git gọi là index)
- git status
- git commit -m "add cute octocat story"
- git add "*.txt"
- git commit -m 'add all octocat files'
- git log (để xem lịch sử commit)
- git remote add origin https://github.com/try-git/try_git.git (để add một remote repo vào, và đặt trên remote repo đó là origin )
- git push -u origin master (để đẩy các file trong local repo lên remote repo)
- origin: tên gọi của remote repo
- master: là tên của 1 local branch (nằm trong local repo)
- -u: để yêu cầu git nhơ các tham số (remote repo nào và local branch nào). lần sau chỉ cần gõ 'git push'
- git pull origin master (kéo từ remote repo có tên là origin => kéo về local branch có tên là master)
- git diff HEAD (để xem sự khác nhau của remote repo: từ lần mình commit cuối cùng => đến hiện tại)
- git add octofamily/octodog.txt
- git diff --staged (để xem những thay đổi khi mình add thêm file vào staging area)
- git reset octofamily/octodog.txt (để unstage file)
- git checkout -- octocat.txt (để đưa cả local branch về lần cuối cùng mà tôi commit file octocat.txt )
- git branch clean_up (tạo mới 1 local branch tên là clean_up, nó sẽ được khởi tạo ban đầu giống với branch hiện tại)
- git branch (để xem hiện tại có những branch nào, và chúng ta đang thao tác trên branch nào)
- git checkout clean_up (để chuyển branch hiện tại : master => clean_up)
- git rm '*.txt' (vừa xóa file khỏi ổ cứng, và cũng 'stage the removal of the files')
- git status (xem trạng thái của staging area)
- git commit -m 'remove all the cats'
- git checkout master (chuyển branch hiện tại sang master)
- git merge clean_up (merge branch clean_up với branch hiện tại)
- git branch -d clean_up (xóa branch clean_up)
- git push (đẩy từ master => remote repo, branch origin)
Wednesday, October 4, 2017
Try git
https://try.github.io/levels/1/challenges/
Subscribe to:
Post Comments (Atom)
git reset: ngược lại với git add
ReplyDeletegit checkout --file (sd để xóa những thay đổi trên file ) (file đó phải chưa được add vào staged, tức là chưa dùng lệnh git add file)
git revert ngược lại với git commit
ReplyDelete