Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Knowing how to make a branch is very basics of using git. If you don’t know how to do it (git checkout -b, btw) you are just outing yourself as someone who doesn’t use git or your just push to master i.e. you are only working on solo projects.

You can switch branch also with ‘git checkout’ and you just ‘git stash’ your changes.

‘git reset’ is fine to reset files, but again if you just want to ”clean” repo you can stash.

You can reset staged files again with ‘git reset’

Mo idea why you would want to checkout a random commit and the start committing from that, but you can also just ‘git reset --hard HEAD~x’ where ‘x’ is number of commits you want to go back. Hard is optional, but I assume that is what you want based on your comment.

Depends on the change. If you change different lines there will be no conflicts.

This is all basic stuff you should know if you are developing code with other people



Threaded merges are easy to screw up, that's why git invented that "rebase" crutch, both be-cause and the-cause it doesn't know which changes are in revision, only the file contents. Not sure how one can look at it and not see (or meet) the problem. "If you change different lines there will be no conflicts." Oh really, I guess I have had no have issues with merging in long branches then, good to know it was fine. You can merge back and forth and it just works. No one itt has merge anxiety, you just do it and it's all fine, and if there are conflicts, it's only for the same lines. Would be laughable if a thing like git had a huge engineering gap here, good thing it doesn't. /s

You can reset staged files again with ‘git reset’

To "revert a file to what was staged" you have to "git checkout" again, it seems, not "reset".

This is all basic stuff you should know if you are developing code with other people

Yeah. It seems that it is basic, until you try using it for something that is not quick one-shot patching of "append-only" code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: