Closed manuel12 closed 1 year ago
Hello Manuel, welcome to the repository, thank you for your work :) Can you please change the title and the body of your commit message please? For something in the idea of
fix(front): typos in form placeholder tutorial
Closes: #168
You can do so by amending your commit using git commit --amend
Now you have 3 commits in your branch, there should be only one, you can learn how to do there: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
Thanks for the info on how to update commit history, it was really helpful :) I updated using the rebase command. My commit log looks like this on my forked repo:
Hope it's ok now.
It is not, you can look at the result on github (commits tab), to be fair you are in a bad situation because you have merge commits in your history. Ideally you should only have a single new commit, based on the latest master, that fix the two typos. I would like to suggest you to restart your branch anew.
First, your main
branch should strictly only contains the commits from our main
branch. You really should refrain from committing directly on the main branch because you end up in a situation where your main branch contains commits that we don't thus when we merge new commits inside of our main branch, you end-up in a situation where your main branch diverged from ours. The next time you'll git pull
git will see that the two branches (our main vs your main) are not compatible and will resolve the problem thanks to a merge commit. Imagine we merge 10 commits on 10 differents days and that you git pull
everyday, you end-up with 10 merge commits on your branch, because of a single typo-fixing commit. That's not something we want.
So you should start by making sure your main branch is synchronised with ours. I assume that you forked our repo and git clone
d it without changing the remote name. So I assume when you type git remote
you only see origin
and when you type git remote get-url origin
you get a link to your fork on github.
You can start by adding our repository (so readthedocs-fr/bin-server) in your list of remotes, we're going to name it upstream
:
git remote add upstream https://github.com/readthedocs-fr/bin-server.git
Then you can ask git to discover all the branches of our repo (including our own main
branch):
git fetch upstream
You should then be able to type git branch -rv
(-r for remote, -v for verbose) and see that there is one origin/main
(your main) and upsteam/main
(our main). You should also see that the commits that are referenced by those two branches are not the same. That's a problem.
So in order to fix that problem, we'll reset your main branch on ours, don't worry we are doing a soft-reset so the changes you did on your side will stay, i.e. it removes the commits, not the diffs.
git switch main # not necessary if you are on main
git reset upstream/main
Now you can git status
and git log
you can see that there are modified files in the git status (so nothing lost youhouuu) and that the main branch on your laptop is synchronised with our main branch. Pay attention that the main branch on your fork (on github) still doesn't use our main branch. You can see that by doing git branch -rv
again. Let's force-push to fix that:
git switch main # again, not necessary if you didn't move to another branch
git push --force origin main
Check that git branch -rv
again, the two upstream/main
and origin/main
should point to the same commit now.
Ok so we fixed that problem, now let's re-commit your changes. This time, start by creating a new branch:
git switch -c manuel12/placeholder-typo
Do a git status
, you should be on the manuel12/placeholder-typo
and there should be modified files.
Now cleanup your working directory so that the only changes lets are the changes you want to commit. Once this is done, go ahead and git add
and git commit
. Set the commit message accordingly to our guidelines (see above) and push your new branch
git add ...
git commit
git push origin --set-upstream manuel12/placeholder-typo
Once it is pushed, check that git branch -br
again to make sure that origin/manuel12/placeholder-typo
exists and contains your new commit.
Now come back here on github and change the branch you want to merge:
If it works, you owe me a beer if we ever meet one day :beer: :stuck_out_tongue: And I would also recommend you to read the git-book in full ;)
up
@Julien00859 Thanks for the detailed explanation. This helped me understand this a lot better.
I followed the instructions and created a new PR https://github.com/readthedocs-fr/bin-server/pull/170
Sorry for the troubles and hopefully this time it works :)
Il manque le "e" à bleue 😄