# Git git clone --no-checkout --depth=1 -b --single-branch --recurse-submodules https://necktwi@github.com/ferryfair/www.git w3 git update-index --skip-worktree # removes file from tracking git rm --cached #removes file from index git reset # I think undos catch ## list tracked files git ls-tree -r master --name-only ## Resync .gitignore git ls-files --cached --ignored --exclude-standard | xargs git rm --cached git commit -a git commit -a -s #commits with sign off message git commit -a —allow-empty # commits with empty message git commit -a —allow-empty-message #allow to commit without any changes git commit --amend #modifies last commit message git commit --amend --no-edit -S #gpg sign last commit git remote get-url origin git remote add Gowtham git@github.com:GowthamKudupudi/musl.git ## add multiple urls git remote set-url --add --push origin ssh://gc.ferryfair.com/~/workspace/www git remote set-url --add --push origin https://necktwi@github.com/ferryfair/www.git git remote get-url --push --all origin ## remote url with .ssh/config git remote set-url origin git@github-gowthammech:GowthamKudupudi/notes.git ## remove or delete remote git remote remove git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=] | --no-color] [--sparse] [--more= | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [( | )…​] git rev-parse --abbrev-ref HEAD git branch # The starred branch is your current git branch # creates new branch from detached branch git branch #new branch with commit git checkout # switches to the new branch git branch --orphan git rm --cached -rf .; # empty the branch git branch -m new_name_for_this_branch #renames current branch ## track upstream git branch -u origin/Linux Linux ## list without alternate screen git config --global pager.branch false git revert -m 1 [sha_of_C8] git log -n 1 --before="10-20-2018" git checkout tags/ ## shallow fetch remote branch git fetch --depth=1 [remotename] [branch]:[branch] git fetch --depth=1000000 ## on "shallow update not allowed" git fetch --unshallow origin git checkout -b [branch] [remotename]/[branch] ## set default push remote branch git push --set-upstream origin ubuntu/xenial git push --all origin #push all branches git push -u origin NewBranch #push new branch git branch -d local_branch #delete branch git push origin --delete remote_branch; #delete branch at remote ## pull from local tmp branch git pull . tmp git submodule add https://necktwi@github.com/necktwi/ferrybase.git ~/workspace/ferrybase/ or vi .gitmodules git submodule update --init --recursive ## if error try git pull --recurse-submodules git submodule update --recursive git push --recurse-submodules=on-demand ## find submodule commit git submodule status git reset HEAD~ #Undo last commit git commit -c ORIG_HEAD #After reset ## Keep changes (soft reset): git reset --soft HEAD~1 git push origin master --force ## revert previous commits. Prefer the reset method if u don't want to ## make new commit of a reverted commit git revert [sha_of_C8] ## revert last commit git revert -m 1 [sha_of_C8] #checkout a single file git checkout file/to/restore ## checkout a file revision with different name git show HEAD^:main.cpp > old_main.cpp ## ignore file from commit git reset -- ignored_file.txt ## to ignore files in local repo add them in git config core.excludesFile ".git/info/exclude" .git/info/exclude #and run git update-index --skip-worktree git stash -p # to stash specific file or git stash -- filename # to stash specific file git stash pop # undo stash git stash drop # removes last stash git stash clear # clears all stash git stash list git stash apply stash@{0} ## show changes done by a commit git show ## will produce the diff between the tips of the two branches. git diff branch_1..branch_2 ## To find the diff from their common ancestor to test, you can use three #dots instead of two: git diff branch_1...branch_2 ## diff two branches git diff master origin/master ## diff a file across commits git diff --no-pager HEAD~2 HEAD -- main.c ## diff 2 files git diff --no-index full/path/to/foo full/path/to/bar ## diff worktree with a revision git diff sha1 ## diff with previous revision git difftool ## see the modified files between two commits git diff --name-status sha1..sha2 ## to see conflicting files during merge git diff --name-only --diff-filter=U --relative ## create patch git diff --binary 20220926-beta > 20220926ROCm.patch ## apply patch git apply ../ApolloAuto-20220926_amd/20220926ROCm.patch #File status flags: Flag Name Meaning M modified File has been modified C copy-edit File has been copied and modified R rename-edit File has been renamed and modified A added File has been added D deleted File has been deleted U unmerged File has conflicts after a merge # The rename or copy score (denoting the percentage of similarity between the source and target of the move or copy). For example "R100" or "C75". So, putting this together with what you cited above, the files you are seeing with R100 status mean that they were moved, and that Git found a 100% match between that file and some other ## apply patch git apply --stat a_file.patch git apply --check a_file.patch git apply a_file.patch ## merge unrelated histories git merge --allow-unrelated-histories ## resolve merge conflicts git mergetool git merge --abort git reset --merge ## to use local or remote files git checkout --theirs -- git checkout --ours -- ## git log with short hash git log --abbrev-commit ## Download a single file git archive --remote=ssh://host/pathto/repo.git HEAD README.md .gitignore **/ git config --global core.editor "vim" export GIT_EDITOR=vim export VISUAL=vim export EDITOR="$VISUAL" ## to push to remote branch git config receive.denyCurrentBranch "updateInstead" git config --global user.name "Necktwi Ozfguah" git config --global user.email "Necktwi@FerryFair.com" git config --global core.autocrlf true git config --global core.autocrlf input git config --global rebase.stat true git config --global color.ui auto git config --global core.pager "less -FRSX" git config --global alias.di diff git config --global alias.ci commit git config --global alias.co checkout git config --global alias.ann blame git config --global alias.st status ## ignore permissions git config --global core.fileMode false git config --global user.signingKey [fpr] git config --global merge.tool emerge ## clean up merge files like *_BASE_*, *_LOACL_*, *_REMOTE_* git config --global mergetool.keepBackup false git config --list --show-origin | grep merge $ git --exec-path /usr/libexec/git-core /usr/libexec/git-core/mergetools/emerge ## instead on linux use find . -name *_REMOTE_* 2>/dev/null | xargs rm ## Git checkout to other folder GIT_WORK_TREE=/someother/folder git checkout -f git --git-dir=/mycode/.git --work-tree=/mycode status # git checkout branch to another folder sudo git worktree add usr/aarch64-unknown-linux-gnu/ aarch64-gnu ## Git check history of particular line git blame -L 1227,1227 WSServer.cpp # check history of a file git log -p -- filename ## merge a file from another branch emerge dev-perl/Error git checkout --patch origin/RPi3B .irssi/ or git cherry-pick --edit git cherry-pick --abort git reset --merge git git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done git fetch --all git pull --all ## trim git gc; #clean and compact git prune; #remove or delete extra files git clean -fdX; #remove untracked, ignored files and directories ## fetch a pull request git fetch origin pull/ID/head:BRANCHNAME # find branch by commit git branch -contains ## debug github echo 'ssh -vvv "$*"' > ssh && chmod +x ssh GIT_SSH="$PWD/ssh" git pull origin master ssh -vvvT git@github.com ## gpg gpg --list-secret-keys --keyid-format=long git config --global user.signingkey 1B5160543211EAB0 #if using subkey git config --global user.signingkey 1B5160543211EAB0! git config --global commit.gpgsign true [ -f ~/.bashrc ] && echo 'export GPG_TTY=$(tty)' >> ~/.bashrc git commit --amend --no-gpg-sign ## Github ### pull request as a patch https://github.com/weppos/whois/pull/90.patch