You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.
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).
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!
// Izymes - Bitbucket apps for efficient teams