Git commit history graph in the terminal

27 Mar 2021 / ERap320

A history graph, like the ones provided by Github and Gitlab are very useful to check how your branches interact at a glance. However, git is always difficult to control and you may want to make sure you didn't break your precious repository before pushing. With this simple command, you can view the usual log visually organized as a graph:

git log --graph --pretty=oneline --abbrev-commit

Alias

If you also think this command may be very useful and you don't want to type it every time, you can create an alias for it. If you are using "Git Bash" for Windows like I do, you can do it this way:

cd && echo "alias git-graph='git log --graph --pretty=oneline --abbrev-commit'" >> .bash_profile

The next time you open Git Bash, git-graph will be available.

Removing files from commits after adding them to .gitignore

07 Mar 2021 / ERap320

It happens way too often. You just set up a brand new repository for the project, you push the initial commit, you check everything is ok and... damn, you forgot the .gitignore. Now you add the .gitignore but the useless files are already in the last commit, and they won't go away.

With this command you can untrack the newly ignored files, so they won't show up in any future commit:

git rm -r --cached .

After this you can go on with the usual

git add .



1