Git
git status
git init
git log
git log --oneline
git branch
git branch 'branchname'
git add .
git add 'filename'
git commit -m "comment"
git switch 'branchname'
git merge 'branchname'
git diff
........renaming-branch----
git switch 'branch_to_rename'
git branch -m 'new_name'
------------git-restore-cmd-------------------------
git restore // remove uncommited text and restore file to last successful commit
git restore --source HEAD~2 myrestore.txt // this will go back to 2 commits of myrestore.txt
git restore --staged <filename> // this wil remove file from staged area
--------------------git-reset-----------------------------------
git reset 798927a //saves files
Git Switch Usage With Examples
Switch to an existing branch
If you want to switch to an existing branch called feature1, you can simply run:
git switch feature1
Create a new branch and switch to it
If you want to create a new branch called feature2 based on the current branch and switch to it, you can run:
git switch -c feature2
Switch to a specific commit without creating a new branch
If you want to switch to a specific commit with the hash 1234567 without creating a new branch, you can run:
git switch --detach 1234567
Merge current branch into master before switching to it
If you want to merge your current branch into master before switching to it, you can run:
git switch -m master
Force-switch to another branch and discard any uncommitted changes
If you want to force-switch to another branch called feature3 and discard any uncommitted changes in your working directory and staging area, you can run:
git switch -f feature3
https://github.com/jobinoutlook?tab=repositories