git add main.texgit commit -m "Add a line from Git"git push
输出的最后一行显示移动了的分支:
53aca61..db007e3 main -> main
更改会出现在编辑器中,已打开的编辑器会自动更新。新文件、文件夹和重命名会显示在文件树中。在 History 中,你的更改被标记为 You (via Git)。那里不会显示你的提交信息。
项目历史中的一次推送
如果 Git 拒绝你的推送
如果项目在此期间发生了变化,Git 会拒绝推送:
! [rejected] main -> main (fetch first)
先获取这些更改,然后再次推送:
git pull --no-rebase --no-editgit push
普通的 git pull 可能会以 fatal: Need to specify how to reconcile divergent branches. 停止。上面的 --no-rebase 选项就是为此准备的:它会合并两边的更改。如果两边修改了相同的行,pull 会以 CONFLICT (content): Merge conflict in main.tex 停止。修复文件,然后运行:
git add main.texgit commit -m "Merge the changes from the editor"git push
站点不接受以下两种情况:
其他分支:! [remote rejected] feature -> feature (wrong branch)。只有 main 分支,所以请把你的工作推送到那里。
强制推送:! [remote rejected] main -> main (forced push prohibited)。请改为把你的更改放在当前 main 之上。
如果 Git 提示 Authentication failed
remote: Enter your Git authentication token when prompted for a password.fatal: Authentication failed for 'https://<your-site>/git/<project-id>/'