Skip to content

Advanced Git Tutorial with Tips and Tricks for Branching

Notifications You must be signed in to change notification settings

abdullahazmy/git-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

git-tutorial

Advanced Git Tutorial with Tips and Tricks for Branching

Important

To contribute, Fork this repository, create a new branch from the main branch, make your changes, and submit a pull request. Include a description of your changes in the pull request description.


Viewing the Commit Pointed by ‘HEAD’

To view the commit pointed by ‘HEAD’, you can use the following command:

git show HEAD

This command will display detailed information about the commit, including the commit message, author, date, and the changes made in that commit. This can be useful when you want to review the most recent changes or understand the state of your repository.

a. Checking Out a Specific Commit

To move ‘HEAD’ to a specific commit, you can use the git checkout command followed by the commit hash or a branch name. For example, to move ‘HEAD’ to a commit with the hash ‘abc123’, you can run:

git checkout abc123

If you don't know how to know the hash, you can use git log --oneline you can add any preferrations to it as you like, you can search about them with git log -h or 'man git log'

b. Moving ‘HEAD’ Relative to the Current Commit

You can also move ‘HEAD’ to a commit relative to the current commit using the git checkout command with the ~ or ^ notation. For example, to move ‘HEAD’ one commit back, you can run:

git checkout HEAD~

Similarly, to move ‘HEAD’ two commits back, you can run:

git checkout HEAD~2

This allows you to quickly navigate through the commit history and switch to a specific commit without specifying the commit hash or branch name explicitly.


Creating a new branch at HEAD

About

Advanced Git Tutorial with Tips and Tricks for Branching

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages