git clone https://github.com/your/develop.git
添加一个叫upstream的remote
git remote add upstream https://github.com/worksg/develop.git
然后fetch upstream
git fetch upstream
git rebase upstream/master
git merge upstream/master
git remote set-url origin https://github.com/your/develop-new.git
git add file1 / git add -A -- file1
git status
git stash save -- myStashTag / git stash save -u -- myStashTag
git stash list
git stash pop stash@{0} / git stash pop
git reset HEAD -- file1
git commit -m "add file1" / git commit -S -m "add file1"
git log
git reset HEAD~
git pull / git fetch origin master && git rebase/merge origin master
git push / git push origin / git push origin master / git push origin master:master / git push origin HEAD:master # 只用 git push 命令时要设置默认主机 git push --set-upstream origin master
git push origin :dev / git push origin --delete dev
git checkout -- file1 # 取消file1在工作区的所有更改
git checkout -- . # 取消工作区的所有更改
git tag v1.0.0 / git tag -a v1.0.0 / git tag -a v1.0.0 -m '' / git tag -s -a v1.0.0 -m '' / git tag -s -a v1.0.0 -m '' <commit id>
git push origin v1.0.0
git push origin --tags # push all tags
git tag -d v1.0.0
git push origin :v1.0.0
git tag -l
git tag -l 'v1.0.*'
git show v1.0.0
git checkout v1.0.0
https://stackoverflow.com/questions/9994093/automatic-merge-of-pull-requests-on-github-without-the-merge-bubble
https://help.github.com/articles/checking-out-pull-requests-locally/
# github / gitea
git fetch origin pull/ID/head:BRANCHNAME
git checkout BRANCHNAME
# gitlab
git fetch origin merge-requests/ID/head:BRANCHNAME
git checkout BRANCHNAME
# 取回upstream到本地
git fetch upstream
git checkout -b upstreamBranch upstream/master
git checkout --orphan newbranch
git rm -rf .
#... Add some files/folders, then
git commit -am "Initial Commit"
git branch -a
- it prevents its creation, if not already created, from everybody except users with Maintainer permission
- it prevents pushes from everybody except users with Maintainer permission
- it prevents anyone from force pushing to the branch
- it prevents anyone from deleting the branch
git push <remote> <branch> --force
# Or
git push <remote> <branch> -f
NOTE:
You only force a push when you need to replace the remote history by your local history.
This happens when you rewrite the local history.
Warning:
force-pushing will overwrite the remote branch with the state of your local one. Warning: be cautious about amending commits that you have already shared with other people.
-
Default Config
git config --global core.autocrlf true
-
提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true
-
提交时转换为LF,检出时不转换
git config --global core.autocrlf input
-
提交检出均不转换
git config --global core.autocrlf false
git config --global core.autocrlf input
git config --global core.safecrlf warn
git config --global core.fileMode false
"files.eol": "\n"
# 这是注释行,将被忽略
*.a # 忽略所有以.a为扩展名的文件
!lib.a # 但是名为lib.a的文件或目录不要忽略,即使前面设置了对*.a的忽略
/TODO # 只忽略此目录下的TODO文件,子目录中的TODO文件不忽略
build/ # 忽略所有build目录下的文件,但如果是名为build的文件则不忽略
doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt
doc/**/*.pdf # ignore all .pdf files in the doc/ directory
/fd1/* # 忽略根目录下的 /fd1/ 目录的全部内容
fd1/* # 忽略目录fd1下的全部内容,包括子目录中的fd1目录
set http_proxy=http://localhost:1080
set https_proxy=http://localhost:1080
export http_proxy=http://localhost:1080
export https_proxy=http://localhost:1080
git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809
# OR
git config --global http.proxy socks5://<host>:<port> / socks5h://<host>:<port>
git config --global https.proxy socks5://<host>:<port> / socks5h://<host>:<port>
# Disable proxy
git config --global --unset http.proxy
git config --global --unset https.proxy