GIT Commands
1 2 3 4 5 6 7 8 9 10 |
git init git config --global user.email "email@example.com" git config --global user.email git remote add origin [remote repository URL] git remote set-url origin [remote repository URL] git remote -v # verifies the new remote URL git remote show git remote show origin # show origin's info includes cloned url |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
git clone git clone --depth 1 https://github.com/example.git # shallow clone [only the latest one commit] git clone ssh://git@159.65.139.96:29418/root/test.git # GitBucket SSH access ssh -i id_rsa -T 159.65.139.96 # SSH test git checkout [file] git checkout --ours [file] # checkout from our branch. git pull git pull --rebase origin master git rebase --continue git submodule sync git submodule update --recursive |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
git clean -f # cleans all untracked files except meta files and files in gitignore. git clean -fd git clean -fdx # cleans all files. git clean -n # performs a "dry run" (not delete but just show the list of target files). rm [file] git rm -f [file] # forcibly removes [file] from the list of tracking files. git add . git add [file] git add -u # (git add . --update) add deleted files by rm command git reset git reset [file] git commit -m "the first commit" git commit --amend # change commit message git reset --soft # doesn't affect local changes git reset --hard # discards local changes git reset HEAD # reset to the latest commit git reset HEAD^ (= HEAD~1) # reset one latest commit git reset HEAD~3 # reset three latest commits git reset --hard 06bda8fb2807ea45df7b09901e4c16e4f78bad49 git update-ref -d HEAD # reset the first commit git push origin master git push origin +master # force to push git push origin ee5b4965a6c0396c7be928f9b1cc7a0dc1c26a57:refs/heads/develop # push only a specific commit git push -f origin HEAD:develop git push -f origin HEAD^:develop git stash git stash apply |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
git status git log git log --graph git log -p # show diff git log --follow [filename] git log --name-only # full path names of changed files git log --name-status # full path names and status of changed files git log --stat # abbreviated pathnames and a diffstat of changed files. git diff # between the staging area and the working directory. git diff --cached # between the staging area and the HEAD. git diff [filename] git diff HEAD # between the working directory and the HEAD. git difftool -d (!= git difftool --dir-diff) [exit:ctrl + c] git show HEAD git show c805e485eb6a86b4cf1b091243e995d06d5a81f1 git show c805e485eb6a86b4cf1b091243e995d06d5a81f1 --stat |
1 2 3 4 5 6 7 8 |
git branch # show the list of branches. git ls-remote origin # show the list of remote branches. git branch <branchname> git branch -m <oldbranch> <newbranch> # rename git branch -d <branchname> # delete git checkout <branch> # change the branch git checkout -b <branch> # create a new branch and change into the branch git merge <branch> |
———————————-
SHALLOW CLONE
———————————-
1 2 3 4 5 6 7 8 9 |
# shallow clone git fetch --depth=1 # unshallow clone git fetch --depth=1000000 git fetch --unshallow git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" git fetch origin |
———————————-
CONFLICT
———————————-
1 2 3 4 5 6 7 8 9 |
git ls-files -u # list of conflicted files 1. git fetch origin 2. git reset --hard origin/master git mergetool git checkout --ours filename.c git checkout --theirs filename.c |
———————————-
DOESN’T SHOW ALL REMOTE BRANCHES
———————————-
1 2 |
git ls-remote origin git fetch |
———————————-
Tutrials
https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting/
———————————-
Regenerate Public Keys for OpenSSH Format
———————————-
1. Open the PuTTY Key Generator
2. On the menu bar, click “File” > “Load private key”
3. Select your id_rsa.ppk file
4. On the menu bar, click “Conversions” > “Export OpenSSH key”
5. Save the file as id_rsa preferably extensionless
——————————–
Terminal
——————————–
find ~/ -iname “*.unitypackage”
find / -type d -name “ora10”
$ grep -i “boo” /etc/passwd
-type d: directory
-i: ignore case
-r: recursive (search for many files)
ctrl + c 処理中断
ps aux
a = show processes for all users
u = display the process’s user/owner
x = also show processes not attached to a terminal
Search for Apache processing.
ps aux|grep httpd
——————————–
Command Prompt
——————————–
ファイル名検索
dir “*.txt” /s/b
——————————–
Bash
——————————–
env
echo $PATH
which python
source .bashrc