git终端操作

git终端使用

第一次使用git看这里

删除远程仓库的方法

克隆远程仓库到本地库:git clone http文件
对需要删除的文件:git rm test.txt (删除文件)
文件夹:git rm -r test/ (删除文件夹)
提交修改:git commit -m "提交信息"
将修改提交到远程仓库:git push

退出vim和node以及其他模式


使用:q或者Ctr+C

fork别人的项目更新主页方法

git fetch upstream master
git merge upstream/master
git push

出现过的问题

git fetch upstream master
fatal: 'upstream' does not appear to be a git repository fatal: Could not read from remote repository.


$ git merge upstream/master
Updating 48477c5..67e6709
error: Your local changes to the following files would be overwritten by merge:
homework/.DS_Store
Please commit your changes or stash them before you merge.
Aborting

  • rm homework/.DS_Store(deleted: homework/.DS_Store)
    git merge upstream/master
    git push

$ git merge upstream/master
Updating e842e43..dbf103a
error: Your local changes to the following files would be overwritten by merge:
webapp/src/public/stylesheets/style.css
webapp/src/views/_head.ejs
webapp/src/views/index.ejs
webapp/src/views/sayToTeacher.ejs
Please commit your changes or stash them before you merge.
Aborting

  • $ git reset --hard
    HEAD is now at e842e43 lesson6
    $ git pull
    Already up-to-date.
    重新三步
    git fetch upstream master
    git merge upstream/master
    git push

$ git merge upstream/master
error: The following untracked working tree files would be overwritten by merge:
homework/.DS_Store
Please move or remove them before you merge.
Aborting

  • You can try command to clear the untracked files from the local
    git clean -d -fx ""
    where -d can be replace with following:
    -x means ignored files are also removed as well as files unknown to git.
    -d means remove untracked directories in addition to untracked files.
    -f is required to force it to run.

How to ignore error on git pull about my local changes would be overwritten by merge?>Your local changes to the following files would be overwritten by merge
What if I want to overwrite them?
I've tried things like git pull -f, but nothing works.
To be clear, I only want to overwrite specific changes, not everything.

  • If you want remove all local changes from your working copy, simply stash them:
    git stash save --keep-index
    If you don't need them anymore, you now can drop that stash:
    git stash drop
    If you want to overwrite only specific parts of your local changes, there are two possibilities:
    Commit everything you don't want to overwrite and use the method above for the rest.
    Use git checkout path/to/file/to/revert for the changes you wish to overwrite. Make sure that file is not staged via git reset HEAD path/to/file/to/revert.
    或者git checkout HEAD^ file/to/overwrite
    git pull

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容