Create a New Repository on the Command Line
Push an Existing Repository from the Command Line
Commit Changes
Commit for Old Dates
Undo Last Commit (Soft Reset)
Show Last 15 Commits in Custom Format
View All Branches
List Local and Remote Branches
View Branch Details
List Remote Branches with Commit Info
Switch to an Existing Branch
Create and Switch to a New Branch
Check Out Specific Commits
Stash Changes
Apply Stashed Changes
Create a New Repository on the Command Line
echo " # return-python" >> README.md
git init
git add README.md
git commit -m " first commit"
git branch -M main
git remote add origin https://github.com/dileepadev/return-python.git
git push -u origin main
Push an Existing Repository from the Command Line
git remote add origin https://github.com/dileepadev/return-python.git
git branch -M main
git push -u origin main
git commit -m " Commit message" -m " Detailed description goes here. You can add multiple lines if needed."
git commit -m " chore: Upgrade dependencies" -m " Including all other packages"
git commit --date=" 10 day ago" -m " Your commit message"
git commit --date=" 2024-01-09 16:00:00" -m " Empty repo files"
Undo Last Commit (Soft Reset)
Show Last 15 Commits in Custom Format
git log -n 15 --pretty=format:" %ad | %h | %G? | %an | %s" --date=iso
git log -n 15 --pretty=format:" %ad | %h | %G? | %an | %s" --date=iso --author=" Dileepa Bandara\|dileepadev
git log -n 15 --pretty=format:" %ad | %h | %G? | %an | %s" --date=iso --author=" [email protected] "
List Local and Remote Branches
git branch -av
git branch -a -v
List Remote Branches with Commit Info
git branch -rv
git branch -r -v
Switch to an Existing Branch
git checkout feature-branch
Create and Switch to a New Branch
git checkout -b < new_branch_name>
Check Out Specific Commits
git checkout < commit_hash>
git stash
git stash save " Descriptive message about changes"
git stash apply
git stash pop