我在Android Studio 3.3.1中将Github用于我的项目 我使用以下代码返回本地存储库和远程存储库。
第1行可以在Android Studio 3.3.1 IDE中启动。
第2行可以在Android Studio 3.3.1 IDE中启动吗?如果可以,该怎么办?
还有,这是否意味着当我使用 force 参数进行推送时,内容会覆盖远程内容而不进行合并吗?
代码
git reset --hard <commit_hash>
git push origin <branch_name> --force
对Geno Chen:谢谢!
但是“强制推送”已禁用,您可以看到下图。我在Windows 10操作系统中使用Android Studio 3.3.1。
答案 0 :(得分:1)
VCS
-> Git
-> Push...
或 Ctrl + Shift + K 。
--force
与git push
一起使用将覆盖本地的远程存储库,而不会合并and can cause the remote repository to lose commits; use it with care。您可能需要先进行git pull
或use a "safer" --force-with-lease
。更新:
Protected branches
-> File
-> Settings
-> Version Control
中列出的Git
不允许强行推入。因此,您必须选择另一个分支而不是master
来进行强制推送,或删除受保护分支的设置。