How can I git push forward by using the “git push”?
I was working on a team project. One of my teammates has made several changes and pushed them into the remote repository. I have also made changes in commit and I want to push them to the same branch in which my teammate pushed. How can I use “git push” with the “—ff—only” to update the remote branch?
In the context of DevOps, there are two methods present to git push fast forward. Here are the methods following:-
Using “git push –ff-only, if you haven’t made the changes from the remote yet, then try this:-
Git fetch
Git merge-base HEAD origin/branch_name
Git push –ff-only origin HEAD:branch_name
If you have fetched the changes then use:-
“git push –ff-only origin HEAD:branch_name”
Using “git push – force-with-lease
“git push –force-with-lease origin HEAD:branch_name
If you do not know about DevOps, –force-with-lease is safer than –force. It is so because, if you use force with the lease, it will prevent accidentally overwriting their changes.