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 "[email protected]"
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 /