Acknowledgments
Preface
local no time to pull remote branch
wrongdoing
correct usage
conclusion
mistake to do development on the Master
git submodule
merge a specific branch commits
merge a branch of an important the commit
the commit errors submitted
after the submission of documents found there forgot to submit
other errors
detached HEAD problem
git large file support
Preface
local no time to pull remote branch
wrongdoing
correct usage
conclusion
mistake to do development on the Master
git submodule
merge a specific branch commits
merge a branch of an important the commit
the commit errors submitted
after the submission of documents found there forgot to submit
other errors
detached HEAD problem
git large file support
Acknowledgments
Foreword
- Git that he is a novice in the local branch no time do not know how to pull (push in from another computer) remote branches, absolutely no alternative but to delete the entire folder to re-clone, then take to the Internet to learn the science, finally know .
- Here there is no focus on what the local branch, you need to pull the remote branch method
There is no time to pull remote local branch
Wrongdoing
git branch link-rosforlv
git checkout link-rosforlv
git pull origin link-rosforlv
-
Because, branch thus created is established on the basis of the master, and then pull down to it, will be merged and content of the master, it is possible clash
Correct usage
- With a
git branch -a
view including remote branch, including all branches: - Use
checkout
the command to get the remote to the local branch, and automatically create tracking
git checkout -b link-rosforlv origin/link-rosforlv
- Or use the -t parameter, it will default to create a remote branch and the local branch of the same name
git checkout -t origin/link-rosforlv
- Fetch may also be used to do:
Git fetch-Link rosforlv Origin: Link-rosforlvBut local branch established by the fetch command is not a track branch, and after the success does not automatically switch to the branch
Epilogue
- After completing only to find there are so many ways to do this, instantaneous feel myself ignorant, Cankuicankui.
Mistakenly do development on the master
- git stash can temporarily modify the current git stack is pressed into the stack, and then pressing the other branches out from the stack to the checkout
# on master
git stash
git branch dev
git checkout dev
git stash apply
# 注意:2,3两步可以合为git checkout -b dev
git submodule
Merging a branch of specific commits
Merging a branch of an important commit
- For example, commit 62ecb3 on branch feature is important because it contains a bug modification of, or other people who want access to content. Whatever the reason, you now only need to 62ecb3 merged into master, and not on the other commits merge feature, so we do use git cherry-pick command:
git checkout master
git cherry-pick 62ecb3
commit the error
After submitting the documents found there forgot to submit
git commit -m 'initial commit'
git add forgotten_file
git commit --amend # 这个命令会将暂存区中的文件提交
Other error
detached HEAD problem
- Use VSCode time, select the time of submission of the origin / global_planner instead global_plannner, results checkout in the past found themselves not in a branch inside, but one in which commit
- The problem is that I actually want to generate a new branch, and save these changes
git checkout global_planner # 执行完毕后仍然在master分支
git checkout otigin/global_planner # 执行完后来到了一个commit,而不是一个branch,此时就是detached HEAD状态
git checkout -b temp # 将此commit生成一个branch
# 之后就可以merge了
git checkout master
git merge temp
git large file support
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com
Solution
#下载git large file 插件
# 到库里面
git lfs install