Live data from Hacker News

Git Exercises

gitexercises.fracz.com

41–45 of 45 posts

Re: Git Exercises

#42

Any tips on fix-old-typo? I'm familiar with interactive rebase, but for some reason I'm not able to get something the `git verify` script likes.

Here's how I did it, but I think there should be a more optimal solution.

Inspect history, see that mistake was made 1 commit ago

  git log
Interactive rebase to edit last 2 commits

  git rebase -i HEAD~2
This will open rebase editor, change first line to below

  edit e794bf2 Add Hello world
  pick 77c37d2 Further work on Hello world
Fix typo in file.txt

stage modified file.txt and amend to commit

  git add file.txt
  git commit --amend

In the editor fix commit message (again?)

This causes merge conflict in file.txt, should be avoidable?

  git rebase --continue
Edit file.txt to remove conflict markers, make it as below

  Hello world
  Hello world is an excellent program.
Again, stage file.txt and continue, just exit the editor, no changes needed on the last commit.

  git add file.txt
  git rebase --continue
You can inspect with git log, but that's it

  git verify

Re: Git Exercises

#43
post #27

Thanks for the resource! I've noticed that if I run a clone `git clone https://gitexercises.fracz.com/git/exercises.git ` it gets cloned in "DETACHED HEAD" mode and I need to checkout master, i.e. `git clone https://gitexercises.fracz.com/git/exercises.git -b master`. Any idea why that is? (It ultimately wasn't a problem once I switched to master, but without doing so there would be no configure.sh script either and…

It's a part of the exercise.

Is it, though? If the instructions in your "How to start?" section don't work, that feels more like a bug. I went through all the exercises and didn't find a point where this was relevant.

Currently, the initial HEAD actually contains the solution for a future exercise. It was also created by a different user than the rest of the exercises.

Maybe the detached HEAD should contain a README with instructions like "You are in detached HEAD mode, reach the master branch to continue"

Re: Git Exercises

#44
Is there a way to restart a challenge when you've made a mistake on(e.g. an extra commit)? `git start ` appears to keep the same state of the git branches associated with the challenge. I'm also noticing when trying to rollback to a previous commit with `git reset HEAD --hard ` that I'm getting `fatal: Cannot do hard reset with paths.`

Re: Git Exercises

#45
post #44

Is there a way to restart a challenge when you've made a mistake on(e.g. an extra commit)? `git start ` appears to keep the same state of the git branches associated with the challenge. I'm also noticing when trying to rollback to a previous commit with `git reset HEAD --hard ` that I'm getting `fatal: Cannot do hard reset with paths.`

Nevermind, `git start` does reset the state I just wasn't understanding the question correctly.
Post reply on HN