Reputation: 2295
I use Github for my project in Android Studio 3.3.1 I use the following code to return to a point both local repository and remote repository.
The line 1 can be launched in Android Studio 3.3.1 IDE.
Can the line 2 be launched in Android Studio 3.3.1 IDE ? If so, how can I do?
And more, does it mean the content of will overwrite the content of remote without merger when I use force parameter to push ?
Code
git reset --hard <commit_hash>
git push origin <branch_name> --force
To Geno Chen: Thanks!
But Force Push is disabled, you can see the following image. I use Android Studio 3.3.1 in Windows 10 OS.
Upvotes: 6
Views: 8133
Reputation: 5214
VCS
-> Git
-> Push...
or Ctrl+Shift+K.--force
with git push
will overwrite the remote repository with local, without a merger, and can cause the remote repository to lose commits; use it with care. You may need to do a git pull
first, or use a "safer" --force-with-lease
.Update:
Protected branches
, listed in File
-> Settings
-> Version Control
-> Git
, is not allowed to do a force push. So you have to choose another branch rather than master
to do a force push, or remove settings of protected branches.Upvotes: 18