DEV Community

Discussion on: Handy Git Commands and practices to improve your workflow

Collapse
 
michaelcurrin profile image
Michael Currin

Thanks for sharing. I rarely use git rm - I usually use rm and commit. And I rename the path to something else if I need to keep it.
I added to my notes regarding cached and -r flags though.

I don't need to use git branch for a new branch. Your usage of git checkout -b is much more common and practical.

And pro tip. I rarely use add if a file already exists...

If i make file changes, then i do this for the directory (or use a dir name).

git commit .
Enter fullscreen mode Exit fullscreen mode

You can also check the comments in your commit message editor window if you need to see which paths are going to be committed. Or use git status before you commit.

Here I commit changes to package.json and package-lock.json without using add but preventing changes in other files getting commited.

git commit package*
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tngeene profile image
Ted Ngeene

this is a new way of looking at things. Really helpful. Thanks Mike.