I'm looking at the tutorial on `git push` at https://www.atlassian.com/git/tutorials/syncing/git-push#:~:text=The%20git%20push%20command%20is,exports%20commits%20to%20remote%20branches.
I'm confused by the following paragraph:
"Push the specified branch to , along with all of the necessary commits and internal objects. This creates a local branch in the destination repository. To prevent you from overwriting commits, Git won’t let you push when it results in a non-fast-forward merge in the destination repository."
Firstly, something is missing after the word "to". Secondly, what is meant by the term non-fast-forward merge?
Hi Philip, welcome to the community!
I understand you need some clarification on 'git push'.
I think the sentence should be like "Push the specified branch to the remote repository, along with all of the necessary commits and internal objects. This creates a local branch in the remote destination repository ...."
Fast forward push
When you work on a git branch and commit code on your local branch, you need to push your work to the remote branch (in bitbucket) to be able to share it with others or create a pull request. Ideally nobody else should be committing and pushing to your working branch. Then every change you commit and push is a direct successor of the previous change. That's called a fast-forward (push) merge.
Non-fast-forward push
If someone else 'interfered' with your branch and pushed 'their' changes to the remote before you pushed yours, your update is not fast-forward any longer, since the last commit is from someone else, but your new commit is based on an earlier stage of the branch. You are in a little bit of trouble now because you need to update your local branch with the 'alien' commit from someone else to merge their and your work before you can push the result, i.e. your work and 'their' work combined, back to Bitbucket (remote).
Conclusion
1. Don't work on shared branches, complete your feature on your branch
2. Run 'git pull' before your commit local changes. It doesn't hurt and in case someone else interfered with your remote branch you are updating your local branch
3. Commit your changes
4. Safely push your changes to remote, they will always be a fast-forward (push) merge in the remote.
Hope that helps!
Ulrich
// Izymes - Bitbucket apps for efficient teams
Hi @phillip_feldman - Thank you for bringing this to our attention. We will get the content you mentioned updated and edited accordingly ASAP. Cheers
@Ulrich Kuhnhardt _IzymesCo_ - Thank you for providing such a thorough and thoughtful answer. Much appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.