Steps To Configure new folder git setup :
git init
git config --global user.name "USERNAME"
git config --global user.email "GITMAILID"
git remote add origin https://github.com/Dharmend/multisite.git
git config core.filemode false
Git Checkout performs the three types of operations :
1 – Checkout files , ( git chekout aa.txt )
2 – Checkout branch , ( git checkout “branch name” )
3 – Checkout commits , ( git checkout k9s7hjkh76 )
git diff :
Command : git diff To show the difference between last commit file and current change file,if you add file in staging area then it will not show the diff, to see the diff use git diff --cached
git checkout vs git revert vs git reset :
git checkout -
download the updated code of the branch and file while HEAD is not changed While git reset, moves both the HEAD and branch refs to the specified commitgit revert-
The git revert command is a forward-moving undo operation that offers a safe method of undoing changes. Instead of deleting or orphaning commits in the commit history, a revert will create a new commit that inverses the changes specified. Git revert is a safer alternative to git reset in regards to losing work requires the id of the commit you want to remove keeping it into your history
git reset-
The git reset command is a complex and versatile tool for undoing changes.
It has three primary forms of invocation. These forms correspond to a command
line arguments --soft, --mixed, --hard.
- --requires the commit you want to keep, and will consequentially remove anything after that from history.
- --hard :
This is the most direct, DANGEROUS, and frequently used option. When passed --hard The Commit History ref pointers are updated to the specified commit. Then, the Staging Index and Working Directory are reset to match that of the specified commit. Any previously pending changes to the Staging Index and the Working Directory gets reset to match the state of the Commit Tree. This means any pending work that was hanging out in the Staging Index and Working Directory will be lost.
2. --mixed :
This is the default operating mode. The ref pointers are updated. The Staging Index is reset to the state of the specified commit. Any changes that have been undone from the Staging Index are moved to the Working Directory.
The Staging Index has been reset and the pending changes have been moved into the Working Directory. Compare this to the --hard reset case where the Staging Index was reset and the Working Directory was reset as well, losing these updates.
To be even more clear, with a log like this: # git log --oneline cb76ee4 wrong 01b56c6 test 2e407ce first commit Using git revert cb76ee4 will by default bring your files back to 01b56c6 and will
add a further commit to your history:
8d4406b Revert "wrong" cb76ee4 wrong 01b56c6 test 2e407ce first commit git reset 01b56c6 will instead bring your files back to 01b56c6 and will clean
up any other commit after that from your history : 01b56c6 test 2e407ce first commit
Head Reset :
git checkout hotfix git reset HEAD~2
I means the hotfix branch revert back to two heads or two commits,
Git Stash :
git stash
git stash list
git stash apply 2 == {it will apply the 2nd stash}
Comments
Post a Comment