Git
เริ่มต้น
- git init
-
git remote add
git remote add orgin https://github.com/laravel/laravel - git add --all
- git commit -m "Init"
- git push origin
- git fetch origin
- git pull origin master
Merge
- เริ่มต้นด้วยการ ไปที่ branch หลัก (master)
- จากนั้นก็สั่ง git merge branch_name จาก branch ที่ต้องการ มาที่ master
Pull
git pull master to develop branch
git pull
git pull origin master developRebase
- git checkout
- git rebase master
Tag checkout
git checkout tags/<tag_name>Tag add
git tag <tagname>Tag list
git tag -lTag push
git push --tagTag delete
-
delete tag in host
git push --delete origin tagname -
delete tag in local
git tag --delete tagname
Update remote url
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git (https://help.github.com/articles/changing-a-remote-s-url/)Delete local branch
- git branch -D branch_name
- git branch | grep 'bug-.' | xargs git branch -d (ลบชื่อเหมือน)
Delete remote branch
-
git push <remotename> --delete <branchname>
git push origin --delete develop
Delete local does note exist remote
git remote prune origin- git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
Stash
- git stash
- git stash pop
- git stash list ดูลิสทั้งหมด
- git stash clear -> clear all
- git stash drop stash@{0} -> drop by list
Reset new file and folder
git clean -fdreset file
git checkout -- <file_name>
git checkout -- git.mdRemeber login
git config credential.helper storemove same file name
git mv -f {old_file} {new_file}multiple account
Sub Module
- git submodule init
-
git submodule add
git submodule add https://github.com/laravel/laravel app/laravel -
Git Pull with Submodule
git submodule update --init --recursive -
Update submodules
git submodule update --recursive --remote
Delete Sub module
- ลบข้อมูล .gitmodules
- ลบข้อมูลใน sumoudle entry ใน .git/config
-
git rm --cached
git rm -cached app/laravel
Easy way
-
git sumodule update --init
git config --global alias.update '!git pull && git submodule update --init --recursive'
git config --global alias.pullall '!f(){ git pull "$@" && git submodule update --init --recursive; }; f'Worktree
- จัดการกับโค้ดโครงการเดียว แต่มีก๊อบปี้หลายชุด
- ไม่ควรใช้กับโครงการที่มี submodule โดยเด็ดขาด
-
git worktree add -b <newbranch>
<old branch>git worktree add -b hotfix hotfix develop -
git worktree add
git worktree add ../new_branch develop -
clean
git worktree prune
Check repo size
git gc
git count-objects -vHGit Workflow
Gitlab
git diff
