In general use, the "remote" is GitHub.
Git Command | Description | Verify |
---|---|---|
git clone <repo-URL> |
Create local repository from remote repository | Change directory into the repository folder and use ls to view the files |
git pull |
Update local repository from remote repository | git log or git status |
git commit -am "<commit-message>" |
Commit current changes to the local repository | git log |
git push |
Update remote repository from local repository | Verify on GitHub |
git log |
View commit log | |
git log --oneline |
View the commit log with the commit id and message | |
git add rainfall.cpp |
Stage changes in the local repository | git status |
git commit -m "<commit-message>" |
Commit staged changes to the local repository | git log |
git status |
View current staged and modified files | |
git diff |
View diff of modified files | |
git diff --staged |
View diff of staged files | |
git tag |
List tags | |
git tag -a v1a -m "Completed v1a" |
Create annotated tag on current commit | git tag |
git tag -a v1a -m "Completed v1a" <commit_id> |
Create annotated tag on previous commit | git tag |
git push origin v1a |
Push tag to server | Verify on GitHub |
git checkout v1a |
Checkout a tag | git status |
git tag -d v1a |
Delete local tag | git tag |
git push origin --delete v1a |
Delete remote tag | Verify on GitHub |
git branch |
View current branch | |
git branch -a |
List of all branches | |
git switch main |
Switch to another branch | git status or git branch |
How to Write a Git Commit Message
The following commands change your global git/GitHub configuration on that particular system.
Git Command | Description |
---|---|
git config --global log.date local |
Set time and date display for git log and other commands to local time |
gh repo set-default |
Set the default repo for gh commands |