From ec0feb632402fd48b1f662d1ef348373aef7fedf Mon Sep 17 00:00:00 2001 From: oleg20111511 Date: Fri, 6 May 2022 00:50:02 +0300 Subject: [PATCH] Add git notes --- git/git-commands.txt | 124 +++++++++++++++++++++++++++++++++++++++++ git/git-submodules.txt | 41 ++++++++++++++ 2 files changed, 165 insertions(+) create mode 100755 git/git-commands.txt create mode 100755 git/git-submodules.txt diff --git a/git/git-commands.txt b/git/git-commands.txt new file mode 100755 index 0000000..6312512 --- /dev/null +++ b/git/git-commands.txt @@ -0,0 +1,124 @@ +LOG: + +elements limit: +git log -2 + +patch: +git log -p + +oneline: +git log --pretty=oneline + +filters: +git log --since=2.weeks --author=trilolol --grep=keywords + +function: +git log -S function_name + +branches logging: +git log --decorate +or +git branch + + +Config: + +levels: +git config --local +git config --global +git config --system + +remove entry: +git config --unset + +replace working directory on push: +git config receive.denyCurrentBranch updateInstead + + +Changes: + +git status + +Diff indexed - working dir: +git diff + +Diff indexed - commit: +git diff --staged (или --cached) + + +Tools: +git difftool --tool-help +git difftool --tool= +git difftool + + +Commits: + +commit with message +git commit -m "message" + +autoindex: +git commit -a + +inlude current index in previous commit: +git commit --amend + + +Remove files: + +Remove from repository: +git rm + +Remove from index: +git rm --cached + +Unindex: +git reset -- + +Move sequence (rm-add): +git mv + +Revert changes: +git checkout -- + + +Branches: + +new branch: +git checkout -b +или: +git branch +или: +git switch -c + +switch branch: +git checkout +или: +git switch + + +Merging: + +step 1, switch to original branch: +git switch master +step 2, run command specifying branch that will be merged in original: +git merge hotfix + +conflicts: +git mergetool + + +Remote: + +add: +git remote add +git remote add name trilolol@example.com:/var/www/folder + +rename: +git remote rename + +upload updates: +git push + +download updates +git pull \ No newline at end of file diff --git a/git/git-submodules.txt b/git/git-submodules.txt new file mode 100755 index 0000000..842cbfa --- /dev/null +++ b/git/git-submodules.txt @@ -0,0 +1,41 @@ +add submodule: +git submodule add [url] + + +config: +diff: +git config --global diff.submodule log +(git diff --submodule) +status: +git config status.submodulesummary 1 +submodule commands: +git config submodule.recurse true + + +cloning: +git clone [url] +git submodule init +git submodule update / git submodule update --init +or +git clone --recurse-submodules [url] + + +change branch: +git config -f .gitmodules submodule.[name].branch [branch] + + +fetch updates for submodules +git submodule update --remote [name] (first update) +git submodule update --init --recursive (update all) +git submodule update --remote --merge (fetch and merge) +git pull --recurse-submodules +in case url changed: +git submodule sync --recursive + + +upload updates for submodules: +git push --recurse-submodules=(check/on-demand) + + +other: +git submodule foreach '[command]'