Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Branch is behind main

Tags:

git

I'm currently just messing around with git and cant figure out how to set a branch to a newer commit. My current git history looks like this:

6be8bf1 (HEAD, main)
701c50a
95cfe6b (origin/mybranch)
1a82bd5
...

How can I edit my history to look like below?

6be8bf1 (HEAD, main, origin/mybranch)
701c50a
95cfe6b
1a82bd5
...
like image 586
flakes Avatar asked Nov 02 '15 18:11

flakes


People also ask

What does it mean to be commits behind Main?

This means every locally created branch is behind. Before preceding, you have to commit or stash all the changes you made on the branch behind commits. Solution: Checkout your local Master branch git checkout master.

How do I push my branch to Main?

To push the branch or you can say to push the changes in the branch to the Github repo you have to run this command “git push origin <the branch name>” in our case the branch name is “main”. After pushing the changes the repo will look like and this is how you can push a branch to a remotely hosted GitHub repository.

How do you fix tip of current branch is behind?

The updates were rejected because the tip of your current branch is behind error can be fixed by pushing to a remote branch. This process is called a Git push, and it debugs the errors of the current branch, which is also known as a local branch.

What is branch upstream?

What is Git Upstream Branch? When you want to checkout a branch in git from a remote repository such as GitHub or Bitbucket, the “Upstream Branch” is the remote branch hosted on Github or Bitbucket. It's the branch you fetch/pull from whenever you issue a plain git fetch/git pull basically without arguments.


1 Answers

If your branch is behind by main then do:

git checkout main (you are switching your branch to main)
git pull 
git checkout yourBranch (switch back to your branch)
git merge main

After merging it, check if there is a conflict or not.
If there is NO CONFLICT then:

git push

If there is a conflict then fix your file(s), then:

git add yourFile(s)
git commit -m 'updating my branch'
git push
like image 95
Bayram Binbir Avatar answered Oct 04 '22 17:10

Bayram Binbir