1. 运行 git pull 遇到 SSH key 未提供问题。
remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.ibm.com/settings/tokens or https://github.ibm.com/settings/ssh
fatal: unable to access 'https://github.ibm.com/IBMPrivateCloud/CP4MCM-docs.git/': The requested URL returned error: 403
解决方案:
a. In the upper-right corner of GitHub webpage, click your profile photo.
b. Click Settings
c. In the left sidebar, click Developer settings
d. Personal access tokens
e. Generate new Token
f. Go to "Windows Credential Manager" and look for your GitHub Enterprise account.
g. Click modify and replace the password with the token you generated.
2. GitHub conflict 如何解决。
如果一个分支中文件为另一个分支的子集的情况,可以看到,我们在一个文件中添加了另一个文件没有的东西。所以可以自动merge。但如果我们两个分支文件不是子集关系,这就尴尬了。GitHub 不会轻易修改任何一个文件,因为 GitHub 也不知道哪个是你需要的。
解决方案:
删除掉其中一份文档的冲突内容,使得一个文档是另一个文档的子集。
a. 提交 Pull request 时 GitHub 会提示有冲突,只有点击 Resolve conflicts 处理完冲突后才可以继续 merge。
b. 点击每个冲突文件,留下需要保留的内容。
注意:<<<<<<< HEAD 到 ======= 中间的内容是 local 提交的。
======= 到 >>>>>>> commit-id 是远程仓库中的内容。
推荐一篇比较好的文章:https://www.cnblogs.com/VergiLyn/p/6701642.html
3. Stashed changes 影响 TOC 显示
某天突然发现 TOC 莫名其妙出问题了。后来想起我在用 pull origin 拉取最新内容的时候遇到一个报错。
Error pulling origin: error: Your local changes to the following files would be overwritten by merge.
然后去 TOC 看了下,看到有下面这样的注释。
====
TOC segment
stashed changes
解决方法:
a. 如果本地有文件改动未提交、且该文件和服务器最新版本有冲突,pull 更新会提示错误,无法更新:要么先 commit 自己的改动再 pull,要么使用 git stash 后再 pull。
git stash #store your local changes
git pull #pull again
git stash pop #restore your local changes
b. 打开有问题的 TOC, 跟同事一样讨论保留那些条目,因为有可能别人刚修改了 TOC,不能不讨论自己瞎改。
注意:The content between Updated upstream and ===== is the content you pull from remote repo, and the content between ==== and stashed changes is your local changes that you haven't commit to remote repo.
4. Git Branch 问题
我的同事问我这样一个问题,说她在 GitHub Desktop 里创建了新 branch,也publish 了这个 branch。可是运行 git branch -l 却找不到这个新 branch。至于为啥要在 GitHub bash 里找这个 branch, 是因为要先进入这个 branch 再运行 git pull origin
解决方法:
a. Check if the branch is created to GitHub by checking in the GitHub webpage.
b. If it's not in GitHub webpage, the branch is not pushed to the remote repository.
c. If it's there in the GitHub webpage, you can run the command git checkout
d. If you are very urgent to use the new branch and couldn't enter the branch, you can delete the branch by the following commands and create a new branch again.
delete the local branch: git branch -d
delete the remote branch in GitHub: git push origin --delete
5. 需要将文档更新 merge 到两个 branch
最近遇到一个新的情况,有两个 release。4月30号前所有的文档更新,需要 merge 到两个 branch A and B.
两个 branch 内容不同,所以显然不能用一个 custom branch 来 pull request (PR).
解决方法:
a. 创建两个自定义 branch:
branch_for_A
branch_for_B
b. 进入 branch_for_A,拉取最新的 branch A 内容
git checkout branch_for_A
git pull origin A
c. 修改文档,merge 到 branch A
d. 进入 branch_for_B,拉取最新的 branch B 内容
git checkout branch_for_B
git pull origin B
e. 修改文档,merge 到 branch B
6. 不知道该怎么处理 conflict 的情况
最近部门将 TOC 从 toc.ditamap 改成了 SUMMARY.md。好处是,以前 local build 后看在本地看不到 TOC,另外 conref 也没有呈现出来。现在改成 SUMMARY.md 后,local build 后能看到 TOC,conref 也能呈现。
问题来了,我不知道远在加拿大的同事做了这样的更改,我早上 pull 最新 branch 内容的时候,告诉我有 conflict。我看了下 conflict, 是关于 TOC 删除。我不确定这是不是误操作,也就不敢乱 resolve conflict.
在有 conflict 的情况下,无法切换 branch,或者创建 branch。
解决方法:
删掉这个 custom 的 branch,重新创建一个 branch,在 git pull origin 拉取最新 default branch 内容。
delete the local branch:git branch -d
delete the remote branch in GitHub: git push origin --delete
create a new branch: git checkout -b