Some Usefull git commands for newbies
To list git user creds/config
git config --list
To add a user email
(Same goes for password, name etc)
git config user.email example@user.email
To add user email
globally (Same goes for password, name etc)
git config --global user.email example@user.email
To remove/unset a user data e.g email
(Same goes for password, name etc)
git config --global --unset user.email
If you have an attribute with multiple values like a user with set with multiple names. If you try to unset with the above mentioned command, it’ll give you an error like this:
warning: user.name has multiple values
To change them (Same goes for email, password etc)
git config --global --replace-all user.name 'Your Name'
Stash
Git provides a stash feature. You’re working on something and need to checkout to another branch or shift to code another module/feature but neither commit the code nor undo this. In this kind of situation, git provides stashing
feature. Running following command make git to stash the uncommitted code.
git stash
You may check how many stashes are there by this command
git stash list
Listing stashes can make you a bit confused about which stash has what. One way is to save stashes with messages so you can identify the stash. Use following command to stash with message.
git stash push -m "Stash Message"
There’s another way that makes you watch the stash contents. But it needs the stash stack. The following command will show you the content of top stash.
git stash show -p stash@{0}
Boom.