I have the following situation: I created a branch, for which I made several commits, I pushed the github, now I wanted to join those commits, which are already in github in one, not to be commits of "garbage". Does anyone know how it works?
I have the following situation: I created a branch, for which I made several commits, I pushed the github, now I wanted to join those commits, which are already in github in one, not to be commits of "garbage". Does anyone know how it works?
You need to do the following:
[1] git checkout -b nomedanovabranch
[2] git checkout nomedasuabranch
[1] This way you will create a new branch and change it to it
[2] This will change you to an existing branch
To merge the commits you will need to merge the branches, you only have to do the following:
git pull origin NomedaBranchQueVoceQuerPegarosCommits
Ready, this way (by pulling), git will automatically merge for you and pick up the commits from the branch you just pulled.
Then you only have to upload to your repository
git add . ou git add -A (Vai adicionar todos os arquivos)
git commit -m "Fazendo um merge"
git push
I hope I have helped! :)
If the commits you want to join from this remote branch are the last commits of it, you need to commit% of the commits in the local branch and then force push to the remote branch. p>
See an example with the squash
branch. First, let's take the last 2 commits and do the squash from them:
git rebase -i origin/master~2 master
Now I force push to the remote branch:
git push --force origin master
A warning: Just do this if nobody opened a branch from one of these commits you want to join.