Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 21, 2022 09:43 am GMT

some useful git commands

Some useful git commands:

git log

git log shows the recent history from the current commit. It might be outdated, if we did not synchronize our local repository with the origin (git pull) or if we checked out an older commit or tag on purpose.

The history shows the commit hashes, committer, commit date, and commit message.

git log -p shows the same history plus the detailed diff of the changed files in each commit.

git log -p mydir restricts the same command to the mydir directory. Useful in a repository that includes build artifacts that we don't want to see in the diff.

git diff

To see the latest changes that have not been added to the upcoming commit yet, use git diff.

If git diff does not show anything, there might still be some changes already staged for commit.

git diff --cached shows us those changes.

git reset

git reset unstages those changes. The files are still changed, and we can see the changes in git diff again.

git reset --hard causes to undo those changes. After a hard reset, our changes will be gone! We might still be able to undo our undo using the local undo history of our code editor.

We can also do a hard reset to a certain commit or branch head, like git reset --hard origin/develop.

git status

While many commands include more or less detailed status information about our current local repository, we can ask git where we are and if there are upcoming changes not yet committed.

git statusOn branch examplenothing to commit, working tree clean

Original Link: https://dev.to/ingosteinke/git-log-p-and-other-useful-git-commands-j84

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To