Having a look at your repository in GitHub...
Imagine the scenario in which main or master is your primary branch, and also you have another branch as dev, and your dev branch is N commits behind main or master, and there's nothing about this living in your local machine.
How to proceed...
Firstly you have to make a clone from the Github repository to your machine, however, at first, your local git doesn't have to know about your secondary branch status, only from the main or master, so Git gets only your remote label branch updated, and there are no commits yet in your local.
So, what you need is at least 1 commit, 1 push to main or master, and 1 pull back to you local.
Do NOT push anything for your dev branch else you would have 1 commit ahead and N commits behind main or master (so, conflicts)...
So, you'll need an auxiliary branch to send a Pull Request to your remote main or master.
Without further ado. How to proceed in this scenario:
Ater cloning the repository...
git checkout -b aux-branch
-> it'll create and checkout the branch
Now, you have to make at least one change in order to record a first commit in you local Git, suposing you haven't anything to implement at the moment... Take the README.md file to change a letter, a space, a blank line more...
git status
-> you'll see your README file was modified
git add README.md
-> to add it to staged area, ready to the commit
git commit -m "modified readme file"
git push -u origin aux-branch
-> it should generate a link that'll lead you to your repository to open and accept the ordered Pull Request.
I use accepting that with Rebase and Merge (the last option in green button when dropdown), after the accepting GitHub will ask you if you want to delete aux-branch... yes you want, so delete, 'cause your main or master now has this newest feature brought by aux-branch.
Now back to your local (Git), proceed this following way:
git checkout main
or master
git branch -D aux-branch
-> to Delete in your local too\
git remote update --prune
-> it makes both fetch and update to your remote.
git pull
-> to receive the newest updates from remote GHub.
git checkout dev
git rebase dev main
or master -> (rebase or merge)
git push -u origin dev
-> climbing the updates to your remote branch
Now go to your GitHub reload the page, drop down to your dev branch you'll see your dev branch is the same as your main/master branch...
So that's it. I hope I helped you guys...
git log -1 -p origin/master
– Corr