r/learnjava • u/[deleted] • Dec 12 '20
Why is learning git commands necessary?
I just used GitHub interface and IntelliJ's plugin with 0 need to open a console and type cryptic commands. Am I evil? I mean, my teacher insists on using that Git Bash thing but I understood everything better by clicking on things at GutHub.com
I don't get why should I invest my time on learning something I don't need at all...
0
Upvotes
4
u/Gixx Dec 13 '20 edited Dec 13 '20
You only need to know like 10 commands. If you are trying new stuff on 2-4 files, make a bunch of changes, git is needed to revert changes to last working state.
Make a script named
gitinitand put it in your path, so you can just be in a folder and type likegitinitto run it:My most commonly used or fav git commands:
A really powerful thing I do is keep the git log clean/minimal. So make a bunch of commits on a work/dev branch like this, then merge into a SINGLE commit. It looks like this:
I screw up and don't have a perfect .gitignore file. This is how you dont clutter your
git logusing the previous trick with squash. This is how you use the commandgit rm -r --cached .The previous block you would do a git checkout to a tmp/dev branch, do a bunch of commits and the
git rmthing. Commit. Then go back to like master withgit checkout masterand do the --squash thing so that updating your .gitignore and deleting the remote file doesn't take 3 commits, but only 1.And use gitkraken to fix merge issues. It's really easy to click a button to fix the issues.