如何在VSCode中修改文件?Git推送至GitHub遇问题求助
问题解答
一、VSCode中修改文件的方法
- 打开VSCode,通过左侧资源管理器找到目标文件,点击打开
- 在编辑区直接修改内容,未保存时文件名旁会出现
*标记 - 按
Ctrl+S(Linux环境通用)保存修改,若文件属于Git仓库,已修改的文件旁会出现大写M标识
二、Git推送问题分析与解决
从你补充的命令行日志来看,最后一次git push origin master已经成功将代码推送到GitHub。之前的推送失败是因为本地仓库尚未关联远程GitHub仓库,添加origin远程地址后推送流程正常完成。
针对你提到的“主文件因未修改,文件名后无大写M标识”:
- Git的大写
M仅标记已追踪且有内容变更的文件,主文件未修改时无标识是正常状态 - 如果主文件从未被Git追踪,需先执行
git add 主文件名将其加入暂存区,再执行git commit -m "提交备注",之后才能随其他文件一起推送
整理后的命令行日志
tomas@art:~/desktop/git/repo56$ git init Initialized empty Git repository in /home/tomas/desktop/git/repo56/.git/ tomas@art:~/desktop/git/repo56$ git status On branch master No commits yet Untracked files: (use "git add ..." to include in what will be committed) README.md nothing added to commit but untracked files present (use "git add" to track) tomas@art:~/desktop/git/repo56$ git add README.md tomas@art:~/desktop/git/repo56$ git status On branch master No commits yet Changes to be committed: (use "git rm --cached ..." to unstage) new file: README.md tomas@art:~/desktop/git/repo56$ git commit -m "created README" -m "Please work test!" [master (root-commit) b53d907] created README 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md tomas@art:~/desktop/git/repo56$ git push origin master fatal: 'origin' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. # 创建GitHub远程仓库repo56后执行: tomas@art:~/desktop/git/repo56$ git remote add origin git@github.com:TB20TB05TB/repo56.git tomas@art:~/desktop/git/repo56$ git remote -v origin git@github.com:TB20TB05TB/repo56.git (fetch) origin git@github.com:TB20TB05TB/repo56.git (push) tomas@art:~/desktop/git/repo56$ git push origin master Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 231 bytes | 231.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To github.com:TB20TB05TB/repo56.git * [new branch] master -> master
内容的提问来源于stack exchange,提问作者Tomas
相关产品推荐
相关产品推荐

