龜龜是最可愛的貓
git clone URL
git clone URL通常只會克隆一個分支,那么如何clone所有分支呢?
git branch -v
* master 093df85 init commit
可以查看到只有一個分支
通過
git branch -a
則可以查看所有隱藏分支
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/testbranch
如果需要在某個分支上工作,需要
git checkout -b testbranch origin/testbranch
Branch testbranch set up to track remote branch testbranch from origin.
Switched to a new branch 'testbranch'
現(xiàn)在再查看
git branch -v
master 093df85 init commit
* testbranch 2bdf3c3 test
可以看到testbranch,且可以在該分支開發(fā)
git push 出現(xiàn) remote error:
remote: error: refusing to update checked out branch: refs/heads/dev
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /media/zym/zym-usb/grayscale/
! [remote rejected] dev -> dev (branch is currently checked out)
error: failed to push some refs to '/media/zym/zym-usb/ggg/'
Solution:
git config receive.denyCurrentBranch ignore
git 放棄工作區(qū)/暫存區(qū)/修改
- 文件已修改,還沒有add 使用
git checkout -- fileA可以撤銷git在工作區(qū)的修改 - 文件已經(jīng)修改并且add進暫存區(qū),分兩步:先用
git reset <文件名>撤銷git add操作(此時更改仍留在工作區(qū)),再執(zhí)行git checkout -- 文件名清除工作區(qū)的改動 - 修改后,文件放入暫存區(qū),且文件再次修改:分三步:先用
git checkout -- 文件名撤銷工作區(qū)的改動,再用git reset <文件名>撤銷git add操作(此時更改仍留在工作區(qū)),最后執(zhí)行git checkout -- 文件名清除工作區(qū)的改動
通過 git checkout -- 文件名 命令可以撤銷文件在工作區(qū)的修改。
通過 git reset 文件名 命令可以撤銷指定文件的 git add 操作,即這個文件在暫存區(qū)的修改。
git clone with submodules
git clone --recurse-submodules