私はクラスメイトと一緒に学校プロジェクトを作っています。そのうちの1人がプログラムのメインを破り、彼はそれをgithubにプッシュします。私は主な変更なしでプロジェクトを持っており、それは完全に動作します。プルをせずにファイルをプッシュでき、悪いファイルを私のものに置き換えることができる方法はありますか?Git push without pull
1
A
答えて
4
他の開発者が関連する変更をプッシュした場合は、それらを消去するだけでなく、両方の変更をマージする必要があります。
デベロッパーが他の意味のある変更を適用した場合、最適な解決方法は、競合を解決して壊れたコードを修正することです。
分岐したコミットから、それらを新しいブランチに移動してから、マージして競合を解決します。
# Create a new branch with your commits
git checkout -b featureBranch
# Get master from origin
git checkout master
git pull origin master
# Add in your changes
git merge featureBranch
# Resolve Conflicts
# Push to origin
git push origin master
あなたは本当にちょうど(私はあなたがを行うことをお勧めしないを)彼のコミットを消去したい場合、あなたは自分のプッシュを強制することができます - これは何を使用してサーバー上のすべてのものを上書きしますあなたのマシンに持っています。
プロジェクトに取り組んでいる他のすべての開発者は、あなたが現在の履歴を変更しているので、そこで追加の行動を取る必要があります。これは勧告されていません。
git push origin master --force
revert
方法もあります。これは、選択されたコミットの変更を完全に逆転させる新しいコミットを作成します。これを使うには、最初にきれいな作業ツリーが必要です。
# Move your commits to a new branch
git checkout -b featureBranch
# Get latest changes from master
git checkout master
git pull origin master
# Create new commit that reverses the other devs changes
git revert hashToRevert
# Pull in your additional commits
git merge featureBranch
# Push to master
git push origin master
2
あなたはおそらくそのコミット戻すgit revert
コマンドを使用することができます。
のgit revertコマンドがコミットスナップショットを取り消します:これは、それはその前のコミット、ドキュメントhereによって行われたすべての変更を元に戻し、新しいコミットを行います。しかし、代わりの プロジェクトの履歴からコミット取り除く、それがどのように 割り出しコミットし、結果のコンテンツを を新しいコミットを追加することにより、導入された変更を元に戻します。
これが完了すると、元のコミットを元に戻すことができます。
関連する問題
- 1. Heroku-Git push without building
- 2. Git Push/Pullを制限する
- 3. ローカルマシンから "git push"するたびにサーバー上の "Git pull"
- 4. git push -fと同じ/反対のgit pull?
- 5. git pullとgit pushを一度に実行する
- 6. git pushとgit pullの違いは何ですか?
- 7. git update pull request
- 8. トラブルシューティングgit pull
- 9. strange git pushエラー
- 10. git pullとgit request-pullの違い
- 11. git pushは動作しませんがgit pullはリモートブランチにあります
- 12. git pull --rebase upstreamとgit push originは早送りを拒否しますか?
- 13. Git Branches without Pulling
- 14. Git Pull対Git Rebase
- 15. git pull --rebase deseired outcome
- 16. git merge without auto commit
- 17. git push -mirrorプルリファレンスなし
- 18. git push操作エラー
- 19. git-subtree pull complications
- 20. Git - Enforcing Pull Embargos
- 21. Rescue git pull
- 22. Git-pull&プッシュプロダクションサーバ
- 23. Git Pull Aborting
- 24. Git pull remote repo
- 25. Git LFS - partial pull
- 26. git pull source tree
- 27. phpstorm git pull --rebase
- 28. git pull for SHA
- 29. git pull with exceptions
- 30. Git Fetch/Pull confuch