Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

question about git push

phillip_feldman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 9, 2023

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?

 

2 answers

1 accepted

2 votes
Answer accepted
Ulrich Kuhnhardt _IzymesCo_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 9, 2023

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

0 votes
Collin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 10, 2023

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. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events