Contents:
Xem thêm: Triển khai Gitlab
git config –global user.name “John Doe”
git config –global user.email “john@example.com”
–global được sử dụng để áp dụng cho tất cả các projects. Nếu bạn ko sử dụng –global thì settings sẽ chỉ dùng cho riêng project đó.
cd project/
git config core.filemode false
Câu lệnh trên hữu dụng khi chúng ta không cần quan tâm đến quyền truy cập files (ví dụ như khi sử dụng Windows).
git config –list
cd existing-project/
git init
git clone https://github.com/user/repository.git
Câu lệnh trên sẽ tạo một thư mục mới có tên giống trên của repo.
git clone https://github.com/user/repository.git .
git help clone
cd repo/
git pull origin master
với origin là remote repo, master là remote branch.
Nếu bạn không muốn merge những thay đổi của bạn, hãy sử dụng git fetch
git remote -v
git remote set-url origin https://github.com/repo.git
git remote add remote-name https://github.com/user/repo.git
git diff
git diff –cached
git diff origin/master
git diff COMMIT1_ID COMMIT2_ID
git diff –name-only COMMIT1_ID COMMIT2_ID
git diff-tree -no-commit-id –name-only -r COMMIT_ID
hoặc
git show –pretty=”format:” –name-only COMMIT_ID
[quangcao]
git diff –cached origin/master
git show COMMIT_ID
git status
git add changed_file.txt
git add folder-with-changed-files/
git commit -m “Commiting changes”
git rm removeme.txt tmp/crap.txt
git mv file oldname.txt file_newname.txt
git commit -m “deleteing 2 files, renaming 1”
git commit –amend -m “New commit mesage”
git push origin master
git log
git log -2
git log -p -2
git log –pretty=oneline
git revert COMMIT_ID
git push origin master
git reset COMMIT_ID
git reset –soft HEAD@
git commit -m “Revert to COMMIT_ID”
git reset –hard
git reset –soft HEAD~1
git reset –hard HEAD~1
git reset –mixed HEAD~1
hoặc
git reset HEAD~1
git reset origin/master
git fetch origin
git reset –hard origin/master
git branch
git branch -a
git diff > patch-issue-1.patch
git add newfile
git diff –staged > patch-issue-2.patch
git add newfile
git diff HEAD > patch-issue-2.patch
git format-patch COMMIT_ID
git format-patch HEAD~2
git format-patch origin/master
git format-patch –binary –full-index origin/master
git apply -v patch-name.patch
git am patch1.patch
git tag 7.x-1.3
git push origin 7.x-1.3
git checkout master
git branch new-branch-name
Lưu ý với hai câu lệnh trên thì chúng ta chưa chuyển sang nhánh mới, mà vẫn ở nhánh master. Phải sử dụng thêm git checkout new-branch-name để chuyển nhánh.
Ngoài ra có thể tạo nhánh mới và chuyển sang luôn bằng 1 câu git checkout -b new-branch-name
git checkout new-branch-name
git cherry -v master
master ở đây là branch mà bạn muốn so sánh
[quangcao1]
git checkout master
git merge branch-name
Ở đây chúng ta merge các commits của branch-name vào master.
git merge branch-name –no-commit –no-ff
git diff branch-name
git diff branch-name path/to/file
git branch -d branch-name
git push origin branch-name
git fetch orgin
git rev-parse –show-toplevel
git rm $(git ls-files –deleted)
git clean -f
xoá cả folder:
git clean -f -d
xem các file trước khi xoá:
git clean -n -f -d
git reset HEAD file.txt
git describe –tags `git rev-list –tag –max-count=1`
git for-each-ref –sort=-committerdate refs/heads/ | head
cd ..
tar cJf project.tar.xz project/ –exclude-vcs
git diff –name-only | xargs tar -cf project.tar -T –
grep -H -r “<<<” *
grep -H -r “>>>” *
grep -H -r ‘^=======$’ *
patch < file.patch
Như các bạn đã biết thì Telegram là một dịch vụ tin nhắn tuyệt vời…
Apache Tomcat là gì? Apache Tomcat là một web server HTTP được phát triển bởi…
20 triệu có lẽ là một mức chi phí khá lý tưởng cho một máy…
Micosoft chính thức phát hành Microsoft Edge Chromium Microsoft đã chính thức tung ra trình…
CentOS 8 đã phát hành ngày 25/09/2019, phiên bản 8 lần này có những thay đổi…
Thời buổi công nghệ phát triển, phần lớn công việc của con người đều có…
Leave a Comment