- https://gist.github.com/Jonalogy/54091c98946cfe4f8cdab2bea79430f9
- https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/
Alternatively check out Meld Merge which is highest rated on Slant
https://sourceforge.net/projects/kdiff3/files/latest/download
KDiff3 Setup
- https://stackoverflow.com/questions/33308482/git-how-configure-kdiff3-as-merge-tool-and-diff-tool
- Install location
C:\dev\kdiff3
- prevent problems with spaces inProgram Files
path
git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/dev/kdiff3/kdiff3.exe"
git config --global mergetool.kdiff3.trustExitCode false
git config --global mergetool.keepBackup false
// For .origni files, also go to: Settings > Configure > Directory > Backup (.orig) - uncheck
// This updates the .gitconfig
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = C:/dev/kdiff3/kdiff3.exe
trustExitCode = false
[mergetool]
keepBackup = false
While on feature branch:
-
git merge master
-
git mergetool
git reset HEAD~
This is how VSCode does it
git reset --soft HEAD~
git reset --soft HEAD~3
git commit -m 'commit message
git push --force
Note: undo if you reset too far back
git reset HEAD@{1}
- StackOverflow How to Undo Reset
git stash save -u -- blog home stash
git config --list --show-origin
actually does seem to delete when syncing - need to check this
git rm -r --cached ./keys
need to be the same on each branch, otherwise won't allow branch checkout
git update-index --skip-worktree keys/CONTENTFUL_CDA.ts
with
--no-skip-worktree
to revert
List the files being skipped
git ls-files -v . | grep ^S
-v
verbose, and grep by:H
cached,S
skip-worktree,M
unmerged,R
removed/deleted,C
modified/changed,K
to be killed
origin (your repo), remote (local), upstream (original)
...that's not forked, alternatively just fork it like a normal person
git remote set-url origin git:new.url.here
git remote rm upstream-remote
- and prune any merged local branches that have been deleted on the remote
git remote update --prune origin-remote
git clone https:sdfadf/asdf.git
git remote -v
- will have implicit
origin
of your remote repo (the original that you forked is not in your git locally)
git branch
- to show branches
git pull origin master
- fetch and merge from origin to master
git checkout -b comment-branch
- creates a new branch and selects it. Make a change
git add .
- staged
git status
- see changes
git commit -m "comment to add to commit"
NOTE -u (upstream) sets tracking for the branch - e.g. sync in VSCode and pull/push will refer to origin as opposed to upstream
Using -u (tracking changes) CREATES A CONNECTION between the remote and local branches, allowing shorthand "git pull" and "git push", and also giving you information about "# commits ahead" etc
git push -u origin --all
- push all branches
- by setting it in config
[email protected]
git config --global user.email "[email protected]"
- verify with
git config --global user.email
git config --global user.name "Brian"
Note: when did the first commit, after adding --global configs, it asked for GitHub Password. 'git log' showed that using private email
git remote add upstream https:github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
- after a fork and clone
git fetch upstream
- Fetch the branches and their respective commits from the upstream repository
git checkout master
- Check out your fork's local master branch
git merge upstream/master
- Merge the changes from 'upstream/master' into your local 'master' branch (preserves local changes)
git push origin master
- Previous step is local only. Now update your (forked) GitHub repo with the sync updates
To avoid non-fast-forward-error (your origin repo is ahead of your local), you do a pull
(usually first step)
git pull origin YOUR_BRANCH_NAME_EG_MASTER
- equivalent to git fetch origin > git merge origin YOUR_BRANCH_NAME
checkout master
branch first, then...
git checkout -b hotfix
combines 'git branch hotfix' and 'git checkout hotfix'
Make your changes and commmit
git checkout master
git merge hotfix
- You can delet the branch now
git pull
- git fetch, git merge
git push
git branch --list
git branch hotfix -d
- or -D
to force delete if warnings
If you've deleted the branch on the remote after the Pull Request -> Merge, then you can do a prune... but only makes sense if the branch(es) was actually deleted on the remote
git remote prune --dry-run origin
then without the dry run part
git branch -d jasmine-testing-framework
- delete a branch
Create a pull request after pushing to your forked repo on GitHub
This is done via GitHub online UI - not via the git bash
terminal
Squash feature branch commit history - then commit to master
git clone --depth=1 <url.git>
- clones with just 1 commit history
git clone https:ORIGINAL_REPO
git remote rename origin upstream
git remote add origin http:github.com/YOU/YOUR_REPO
Note, you could alternatively clear their remote with
remote set-url
git remote set-url origin https:github.com/YOU/YOUR_REPO
- point to origin from theirs to yours
NOTE -u (upstream) sets tracking for the branch - e.g. sync in VSCode and pull/push will refer to origin as opposed to upstream
git push -u origin master
- master
set up to track remote branch master from origin.
git push -u origin --all
git tag --list
git tag -a v0.3 -m "Tag Message"
git push origin <tag-name>
git push origin --tags
git branch -m when branch is checkout branch
git branch -m <oldname> <newname> when on a diff branch
// On branch feature/A rename to feature/B
git branch -m feature/B
// Delete old branch on remote
git push origin --delete feature/A
git fetch --prune
git push origin -u feature/B
git fetch <remote> <sourceBranch>:<destinationBranch>
Works with fast-forwards only
git fetch origin master:master
This is what you probably want
git reset HEAD~
git log --oneline
(copy the hash)
git revert [hash]
- VSCode: Unstage All Changes, and push
If the merge is still in progress
git merge --abort
git reset --hard
- List all branches beginning with bugfix/
git for-each-ref --format='%(refname:short)' refs/heads/feature
- Delete all those local branches (use -d to do it with warnings, -D to force)
git for-each-ref --format='%(refname:short)' refs/heads/feature | xargs git branch -D
-
Checkout the feature branch with the changes
-
Choose a branch you want to compare it to e.g. the branch it was created from master
-
If you are in client folder, create a folder to save the patches to e.g. patches-dir
-
Run command
git format-patch master -o patches-dir
-
Checkout your new branch - the one you're applying patches to
-
Apply the patches as commits
git am patches-dir/*.patch --ignore-space-change --ignore-whitespace
https://stackoverflow.com/questions/18357511/git-remove-committed-file-after-push/18357621
- check out the previous (unchanged) state of your file; notice the double dash
git checkout HEAD^ -- /path/to/file
- commit it:
git commit -am "revert changes on this file, not finished with it yet"
- push it, no force needed:
git push
- get back to your unfinished work, again do (3 times arrow up):
- git checkout HEAD^ -- /path/to/file
- Revert a range of commits inclusive. Creates a new commit (staged changes) with the range reverted
git revert --no-commit a85434e^..556e07d
To simplify the rebase process it makes sense to reset all commits into a single one.
Don't use
git pull origin master
on your feature branch at any stage if using this approach
git log -n 3
git rev-list master.. --count
git reset --soft HEAD~2
- reset last two commits.--soft
means they become Staged Changesgit commit -m "D-xxxx: Bugfix"
- merge all your commits into one commitgit push --force
to overwrite remote branch
Rebasing
git fetch --prune
git fetch origin master:master
orgit checkout master
,git pull
git rebase master -i
- invoke rebase process against master branch. -i means interactive mode to resolve merge conflicts.esc :wq
- should be just onepick xxx D-xxx: Bugfix
command in thegit-rebase-todo
May give message Successfully rebased and updated...
, in which case use
git push --force
If conflicts, fix these, then git add
to Staged Changes - you don't change the commit message
git rebase --continue
git push --force
- push to remote, --force if remote branch already existsgit push origin bugfix/DE-xxxxx
- if doesn’t already exist
git rebase --abort
if all is going haywire!
npm root -g
- C:\Users\b.HQ\AppData\Roaming\npm\node_modules
npm init -y
- creates the package.json
npm config ls -l
- config - full list
npm config list
- shorter
npm list -g --depth=0
- List all files
npm list -g --depth=0 --link=true
- view all npm link
libraries
npm outdated --global
// Outdated packages
npm show react-native@* version
- released versions
npm show react-native versions
- pre-release included
npm view <package-name> dist.tarball
npm view @angular/[email protected] dist.tarball
sudo npm run start:tasks -- -- abc
// passes string 'abc' to the first task
// Can be accessed in Express.js with process.argv[2]
"start:tasks": "run-p \"start:server -- {1}\" start:ui",
nvm alias default 0.12.7
// use this if nvm use
isn't working