Setting
Stop asking for username and password
- Find the
remote.origin.url
using the command:git config -l
- Run the command:
git config remote.origin.url https://{YOUR_USER_NAME}:{PASSWORD}@github.com/{YOUR_USER_NAME}/{REPOSITORY_NAME}.git
Tag
Create lightweight tag
1 | git tag TAGNAME |
ex. git tag v1.0
, git tag a-bc
Delete tag
1 | git tag -d TAGNAME |
Push tag
1 | git push [origin] --tags |
Better use
git push --follow-tags
Reference: https://therightstuff.medium.com/the-rights-and-wrongs-of-git-push-with-tags-998667eaed8f
Force Push
Exist repository overwrite
Force push
1 | git push -f origin master |
Stash
Used when you want to go back to the starting point of the commit.
git stash
1 | git stash |
Save the current change (either before or after git add
, after git stash pop
, files will be in the stage before git add
). Go back to the starting point of the commit, to do something else (branch out). DO NOT edit the fresh commit (after git stash
) directly, otherwise may cause conflict. In this case, use git stash show
to find the difference and edit them in the “fresh commit”. Then use git stash clear
to drop all stashes, or use git stash drop <STASHNAME>
. Then use git add
and git commit
(not git commit -a
).
git stash list
1 | git stash list |
List stash entries and its name.
Get back to work
1 | git stash apply <STASHNAME> |
Questions
- Working at branch ‘a’, has not commited (could have done
git add .
). When create a new branch ‘b’ now, every changes in branch ‘a’ will carry over to the new branch, and after doing a commit in the new branch ‘b’, branch ‘a’ will look like anything unchanged (nogit add .
too).