Diễn đàn Nhật Bản - diendannhatban.info

NHÀ PHÁT TRIỂN - DEVELOPERS - 技術開発 => SOURCE CODE => GIT => Tác giả chủ đề:: admin trong Thứ bảy, 8/10/2016, 08:46:33 am

Tiêu đề: Câu lệnh GIT thông dụng
Gửi bởi: admin trong Thứ bảy, 8/10/2016, 08:46:33 am
1. Giới thiệu
*Keyword
- Tracking: quản lý, theo dõi mã nguồn

2. Một số câu lệnh GIT thông dụng
# Xoá tất cả file và thư mục hiện chưa được tracking bởi git
Code: Bạn không thể xem liên kết này. Đăng ký hoặc Đăng nhập
git clean -f -n // kiểm tra file nào sẽ bị xoá
git clean -f // chỉ xoá file
git clean -d // chỉ xoá thư mục
git clean -fd // xoá cả file và thư mục

# SSH Đổi mật khẩu passphrase
Code: Bạn không thể xem liên kết này. Đăng ký hoặc Đăng nhập
ssh-keygen -p
# Start the SSH key creation process
Enter file in which the key is (/Users/you/.ssh/id_rsa): [Hit enter]
Key has comment '/Users/you/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase): [Type new passphrase]
Enter same passphrase again: [One more time for luck]
Your identification has been saved with the new passphrase.

# Trở về trạng thái trước khi commit (Undo về 1 commit trước đó)
Code: Bạn không thể xem liên kết này. Đăng ký hoặc Đăng nhập
git reset HEAD~1

# Xoá file trên tất cả các commit
Code: Bạn không thể xem liên kết này. Đăng ký hoặc Đăng nhập
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch PATH-TO-FILE' --prune-empty --tag-name-filter cat -- --all

# Submodule
Code: Bạn không thể xem liên kết này. Đăng ký hoặc Đăng nhập
# pull latest of all git submodules
# git 1.8.2 or above, the option --remote was added to support updating to latest tips of remote branches
git submodule update --remote --recursive
# git 1.7.3 or above
git submodule update --recursive

git pull --recurse-submodules
git submodule update --remote --merge # update submodule to the latest commit

# Remove submodule
git rm --cached path_to_submodule

3. Tham khảo
- http://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-branch
- https://help.github.com/articles/working-with-ssh-key-passphrases/
- https://github.com/tj/git-extras/pull/80
- https://stackoverflow.com/questions/1030169/easy-way-to-pull-latest-of-all-git-submodules