Git指令彙整

在本機下載專案 git clone user@website:my/path/projectname.git git clone git@github.com:zlargon/git-test.git 在本機下載專案 git clone -b fix-header git@github.com:zlargon/git-test.git 在本機下載專案 git clone -b fix-header --single-branch git@github.com:zlargon/git-test.git 在本機下載專案 git clone -b fix-header --single-branch git@github.com:zlargon/git-test.git 分支 列出本地(local)分支 git branch 列出遠程(remote)分支 git branch -r git branch --remotes 列出本地、遠程全部分支 git branch -a git branch --all 新增分支 git branch branch_name 新增develop git branch develop 將分支develop合併於master git checkout master git merge develop --no-ff 顯示小耳朵 git log --oneline --graph 刪除本地(local)分支 git branch -d branch-name 刪除遠程(remote)分支 git push origin -d branch-name git reset --hard git clean -f git clean -df git rebase HEAD~1 --exec "git commit --amend --no-edit --date 'now'" git rebase HEAD~2 --exec "git commit --amend --no-edit --date 'now'" Status git status 只顯示已上傳檔案的Status git status --untracked-files=no git status -uno Add git add filename 取消Add git reset filename git restore --staged filename Commit git commit -m "commit message" 取消Commit git reset --soft HEAD^ 取消Commit + Add git reset --hard HEAD^ 修改Commit訊息 git commit --amend -m "new msg" 修改Commit日期 git commit --amend --no-edit --date "now" Push git push --set-upstream origin develop Push之前的commit git push origin last_known_good_commit:branch_name 取消Push = 強制Push之前的commit git push -f origin last_known_good_commit:branch_name 例如 git push -f origin cc4b63bebb6e6dd04407f8788938244b78c50285:develop

留言

這個網誌中的熱門文章

私有IP

echo "text" > file 發生 Permission denied