Some usefull git commands you can use
git --no-pager branch
git log
This displays the commit, date, user, message. Press arrow up / down to move through the list. Press q
to quit.
Bitbucket
git archive --remote=ssh://[email protected]/<user>/<repo>.git --format=zip --output="<archive>.zip" <branch>
git diff-tree --no-commit-id --name-only -r <commit-hash>
Used in combination with the git log
command you can check which files were changed in a specific commit.
If you want only the remote URL:
git config --get remote.origin.url
If you require full output or referential integrity is intact:
git remote show origin
When using git clone (from GitHub, or any source repository for that matter) the default name for the source of the clone is "origin". Using git remote show
will display the information about this remote name. The first few lines should show:
$ git remote show origin
* remote origin
Fetch URL: [email protected]:jaredpar/VsVim.git
Push URL: [email protected]:jaredpar/VsVim.git
HEAD branch: master
Remote branches:
Sometimes you work on something and realise your on the wrong branch or need to fix something in your current branch and push that to your remote repository.
This is where git stash
comes in. With this command you can track your current file state (with their changes) and reapply them at a later stage.
To start off use:
git stash
Later on you can just use the following command to apply the latest stash
git stash apply
You can also verify if you have multiple stashes
git stash list
This will result in a list with all your stashes like below
stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert "added file_size"
stash@{2}: WIP on master: 21d80a5 added number to log
Listing the changed files can be done with
git stash show stash@{1}
Dropping a stash can be done with
git stash drop stash@{1}
More information can be found at the Git documentation
Stash with a custom message can be accomplished with
git stash save your custom message can be set here
Key part here is the save
key word to set your custom message