path/command | description |
---|---|
/ |
root directory |
~ |
my home directory |
~/.zshrc |
config file, there are more of them (.zprofile, .zlogin, .zenv) |
~/.oh-my-zh |
folder |
alias |
a list of diffetent commands/aliases from several sources (lib/plugin etc. folders) |
-
-
Save jtrfs/23e754b919c23a84d55fa6a2ad3d51c7 to your computer and use it in GitHub Desktop.
Based on this article and this gist.
Still working on it ...
git
config
--global
user.email "[email protected]"
git config --global user.name "Your Name"
git config --global core.editor "nano"
- setting the editorgit config --global color.ui true
--local
and--system
as well
git config
--list
git
init
git
add <filename>
git
add .
... add all the files to the repo
git
commit -m
"Message about the change goes here" <filename>
git commit
-am
"Message about the change goes here"
... commit all changes to git of muliple files - no filenames needed
git
log
Changes to files are put in a Checksum SHA-1 hash 40digit value containing parent hash, author and message.
HEAD is the latest commit of the checked out branch
git status
(the command 'git status' tells which files are not added or committed from Working to Staging to Repository)
git commit -m ""
(Commits and changes to all files that are in Staging into Repo)
git diff
(show changes between Working and Local Repo, no file supplied shows all files)
git diff --staged
(shows changes between Staged and Local Repo)
git rm file.txt
(will remove file from working then git commit -m "" to also remove from Repo)
git rm --cached file.txt
(leaves copy of file in Working but removes from Staging and Repo)
git mv
(rename or move files - then git commit -m ""
to move to Repo)
git commit -am "text goes here"
(adds all files straight to Repo from Staging if they have changes - meaning they skip git add
)
git checkout -- file.txt
(restore Repo file to Working Directory using current branch)
git reset --soft HEAD^
(restore repo file to staging)
git reset HEAD file.txt
(Move a Stage file out of Stage back to Working)
git commit --amend -m "message" file.txt
(Change last commit to Repo - only last one can change)
❓Reverting --soft
--mixed
--hard
will go back to previous commits
git log
(gets the sha1s so you can see the commits where you want revert back to)
git reset --soft sha
(changes Repo but not Staging or Working)
git reset --mixed sha
(changes Repo and Staging but not Working)
git reset --hard sha
(changes all 3 Tiers)
git clean -f
(remove untracked files from Working)
.gitignore
(ignores files to track in Working / track the .gitignore file)
❓ .gitignore_global
(global ignore - create in home folder)
- .DS_Store
- .Trashes
- .Spotlight_V100
git config --global core.excludesfile ~/.gitignore*global
(add to gitconfig)
git rm --cached file.txt
(leaves copy in Repo and Working)
Add an invisble file to a folder like .gitkeeper
then add and commit
git
ls-tree
HEAD
git ls-tree master
git
log
--oneline
git log --author="Neil"
git log --grep="temp"
git
show
dc094cb
(show SHA1) ... 7 characters is enough
git branch (Show local branch name - the asterisk _ is the one we are on git branch -r (Shows remote branches) git branch -a (Shows local and remote) git branch newbranch (creates a new branch) git checkout newbranch (switch to new branch) git checkout -b oldbranch (creates and switches to new branch) git push origin newbranch (Push new branch to remote)
git diff master..otherbranch (shows diff) git diff --color-words master..otherbranch (shows diff in color) git branch --merged (shows any merged branches)
git branch -m oldname newname
git branch -d nameofbranch
git merge branchname
(be on the receiver branch to merge the other branch)
Merge Conflicts between the same file on 2 branches are marked in HEAD and other branch
git merge --abort
(Abort basically cancels the merge)
git stash save "text message here" git stash list (shows whats in stash) git stash show -p stash@{0} (Show the diff in the stash) git stash pop stash@{0} (restores the stash deletes the tash) git stash apply stash@{0} (restores the stash and keeps the stash) git stash clear (removes all stash) git stash drop stash@{0}
- You can push to and fetch from the remote server, merge any differences - then push any new to the remote - ❓(na toto se musim jeste podivat, nedava mi to smysl) 3 branches work remote server branch, local origin master and local master
- Create a repo in GitHub, then add that remote to your local repo
- You will need to add a SSH key from your local machine and store it in GitHub - ref: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
git
remote add
origin https://....git
(origin (just a label/name) can be named whatever followed by the remote = git repo url)
git remote
(to show all remotes)
git remote show origin
(to see remote URL)
git remote remove origin
(to remove remote)
git remote rm origin
(to remove remote)
Cloning a GitHub Repo - create and get the URL of a new repository from GitHub, then clone that to your local repo, example below uses local repo named 'nameoffolder'
git
clone
https://github.com...git nameoffolder
git push -u origin master
- push to remote (origin) and branch (master) ... since when we pushed the local to remote we used -u
parameter then the remote branch is tracked to the local branch and we just need to use... git push
git push origin
newbranch
(push a specific branch to a remote)
git fetch origin
- pulls down latest committs from remote origin/master not origin, also pull down any branches pushed to Repo
❗️ Fetch before you work ❗️ Fetch before you pull ❗️ Fetch often
git merge origin/master
git pull
- you can also do git pull which is = git fetch
+ git merge
git branch branchname origin/branchname
(this will bring the remote branch to local and track with the remote)
git branch -d branchname
❓(Checkout and switch branch and track to remote) ❓git checkout -b nontracking origin/nontracking
git push origin --delete branch
git checkout path-to-file
(restores a file before it is staged)
git reset HEAD path-to-file
(if it is staged - restores a file from last commit and then git checkout path-to-file)
git checkout HEAD^ path-to-file
(if is staged and committed - restores from last commit)
git reset --hard HEAD^
(restore prior commit)
- Keeping the local synced with the origin after the local is reset, reference: http://stackoverflow.com/questions/17667023/git-how-to-reset-origin-master-to-a-commit
git push --force origin master
git rm --cached filetoremove
(Removes a file that is committed from repo but leaves it still locally - handy when you've added something that you don't want tracked)
- Undo last push to github - below forces commit entered in to overwrite remote - so in case below origin is local and master is remote)
git push -f origin last_known_good_commit:master
git tag -a v1.0.0 -m "add message here" (tagging a commit with a version number)
git push --tags (pushes tag info to master remote)
(You can checkout a commit and add a tag to that commit by checking out its SHA)
git checkout f1f4a3d (checking out a commit - see the commit SHAS by git log)
-
Changing Tag to different commit
-
Deleting the tag
git tag -d v1.0.0 /*change version number to suit - we are deleting it here git push origin :refs/tags/v1.0.0 /*push change to remote - change 'origin' to your remote name
-
Adding it again - but this time it would be to the latest commit */ git tag v1.0.0 /*create new tag - change version number to suit) git push origin master --tags (assign to latest commit - change 'origin' to your remote name)
- Have the Fork already created in Github
- http://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository
- make a local copy of the fork -
git clone [email protected]:me/myfork.git myfork
- cd into the repo
- make an upstream remote repo -
git remote add upstream https://github.com/theotherguy/theoriginal.git
- check all the repos -
git remote -v
- get the original repo -
git fetch upstream
- ensure you are in your local master branch -
git checkout master
- rewrite your local master branch on top of the upstream -
git rebase upstream/master
git push -f origin master
(needs -f the first time after rebase)
This will result in the fork master branch being 'even' with the original master branch
git push --set-upstream dev master (Here the remote 'dev' branch is set as Upstream to the local 'master' branch)
git branch -vv (Shows which branch is the Upstream, if you need to change just use the preceeding command again)
git checkout -b newbranchname
git pull https://github.com/username/the-repo.git theirbranchname
git rm --cached submodule_path # delete reference to submodule HEAD (no trailing slash) git rm .gitmodules # if you have more than one submodules, # you need to edit this file instead of deleting! rm -rf submodule_path/.git # make sure you have backup!! git add submodule_path # will add files instead of commit reference git commit -m "remove submodule"
ofd
- otevri ve Finder - open finder dirpfd
- vypis cestu, co je ve finder - print finder directorypfs
- vypis cestu, co je ve finder - print finder selectioncdf
- vleze do dane slozky, co je ve Finder - cd finder
z
- rychle najde umisteniexec zsh
ulozi zmeny asishowfiles
- ukaz ve Finder skryte souboryhidefiles
- skryj ve Finder souborypwd | pbcopy
- copy pathcode -r .
- otevre ve VSCode aktualni slozkunpm root -g | pbcopy
- copy path to packagesdu -sh <folder>
- velikost te slozkydu -shc path/*
- velikost podslozek- nebo
du -hd 1 <folder>
- velikost podslozek
brew list
- vypsat co mambubu
- update / outdated / upgrade / cleanbrew help
- pomocman brew
- manualbrew commands
- prikazy, co mam k dispozicibrew uninstall [formula|cask]
- odinstaluj co
n -h
- help ...vidim dalsi moznostin ls
- vypise, co mamn
- vypise, co mam ... muzu si vybratn --latest
- ukaze latest/current moznostn latest
- instaluje latest moznostn --lts
- ukaze lts/stable moznostn lts
- instaluje lts moznostn <version>
- instaluje verzi
ga
- git addgaa
- git add --allgb
- git branchgcmsg "message"
- git commit -mgsw <branch>
- git switchgswc <new_branch>
- git switch -cgca!
- git commit --amend - upravit posledni komit, in VIM editor:- i (enter insert mode)
- ESC (leave insert mode),
- :wq (save and leave)
gpsup
=git push -u origin $(git_current_branch)
❗️
- markdown: md guide site
- GitHub: How to add Shields video
- shields website