Git 操作

git commands

2017-06-12  本文已影响0人  于恺雯

1. To see the URL of local repository

git remote show origin

2. View current remote

git remote -v

3. Remove remote

git remote rm <remote_name>

4. git Undo 回滚

详情请见: How to with Git: Undo Command

我一不小心把代码都删了,然后push了一下;结果不仅本地仓库,远端仓库代码都没了,最新的commit就是删除所有代码的commit。但是,上一条commit是上传完整代码的commit,所以我要回滚到上一条commit。

STEPs:

1. 找出正确的,想要回滚回去的commit

git log

2. 当前本地状态为之前递交这个commit前的状态,不要忘记最后那个点

git checkout <commit_Id> .

3. 因为是递交这个commit前的状态,所以查看git status可以看见所有没有commit 的文件

git status

4. git reset回滚回正确的commit,然后用ls查看,文件回到本地,而且GitHub远端仓库文件也回来了

git reset <commit_ID>

ls

上一篇 下一篇

猜你喜欢

热点阅读