Created: November 6, 2021 1:17 AM
- Reviewed
Git Commit History # :
-
Going back to a commit #
π² git checkout < hash-code >
Rename master to main #
-
Configure your user name
π² git config --global user.name "your_github_username" -
Configure your email id used for github
π² git config --global user.email "your_email@example.com"
List hidden files
- gives the
<hashNumber>
and details - to exit git log β
q
orz
-
enter vi
π² vi -
exit vi editor
π² [ESC] : x
-
To create file
π² touch < file > -
To look inside file
π² cat < file > -
Remove/Delete file
π² rm -rf < file >
-
Adding a particular file
π² git add < file > -
Adding all the files
π² git add . -
To add all files with the particular extension
π² git add *.< fileExtension > -
Un-stage particular commit changes
π² git reset < hashNum > -
Removing file from stage
π² git restore - - staged < file > π² git rm - - cached < file >
-
Adding files to Stash
π² git stash- adds all the files to stash
-
Adding message to a stash
π² git stash save "< message >" -
Pop the Stash files
π² git stash pop -
To clear the stash
π² git stash clear -
To list stash
π² git stash list -
To Pop particular files
π² git stash pop stash@{indexNo}
-
Adding remote Repo to local repo
π² git remote add origin < https://gitRepoURL.git > -
To check attached URLs
π² git remote -v -
To push changes to remote Repo
π² git push origin < HEAD Branch >- for main or master branch it will be
git push origin main
orgit push origin master
- for branch β
git push origin <branchName>
- for main or master branch it will be
-
To pull remote repo commits/changes
π² git pull -
To remove remote repo URL
π² git remove remote origin -
To update remote repo
π² git remote set-url origin < newRemoteRepoURL.git > -
To add add Upstream (forked repo URL)
π² git remote add upstream < URL > -
To check remote repo
π² git remote -
To clone remote repo
π² git clone < repoURL >
-
To Create new branch
π² git branch < branchName > -
To Switch to particular branch
π² git checkout < branchName > -
To Create new branch and switch to it
π² git checkout -b < branchName > -
Merge the current branch
π² git merge < branchName >- make sure you've switched to the branch you want the other branch to merge with.
-
To move previous directory
π² cd .. -
To move to home directory
π² cd ~ -
To move to root
π² cd /