These will help me with npp-usermanual and team:npp-user-manual-admin
git rebase
, but that doesn't appear to be an option through the github web interface; urgh.git pull # svn update: sync my working copy with github origin (my fork) git remote -v # list origin (my github fork) and possibly upstream (official master) git remote add upstream https://github.com/notepad-plus-plus/npp-usermanual.git # if needed, add the upstream URL git remote -v # should list both now git fetch upstream # grab official changes (but not yet merged with working copy) git checkout master # svn switch ^^/trunk # make sure I'm in the master "branch" git merge upstream/master # actually sync my working copy with github upstream (official master) git push origin master # this puts the changes back in _my_ github
git checkout featureBranch # svn switch ^^/branches/featureBranc # make sure I'm in the right branch git merge origin/master # actually sync my working copy with github origin (master) #git merge master # (alternate: I think it works without the origin/ prefix) git push origin featureBranch # puts the changes back in my github
git remote add upstream /url/to/original/repo # already done via above git fetch upstream # grab official changes git checkout master # svn switch ^^/trunk git reset --hard upstream/master # nuke it! git push origin master --force # push the changes back into _my_ github
Derived from Git for SVN users and other similar resources in the references section. Collating here (mainly because the original doc is now only available through the wayback machine).
svn | git | notes |
---|---|---|
main | ||
svn checkout URL | git clone URL [DIR] | checkout to specified directory (defaults to same as repo name) |
svn checkout URL/subfolder | git clone -n --depth=1 --filter=tree:0 URL cd newDirectory git sparse-checkout set --no-cone subfolder git checkout |
partial checkout => sparse checkout ...
SO Answer => keeps the full hierarchy even with subfolder/deepfolder |
svn update | git pull | Grab the most recent remote copy to working copy |
svn info | git remote -v or git remote show origin | info about the repo/checkout |
svn log | less svn log -l 5 | git log git log -5 | Show the log Show the last 5 commits of the log |
git log ABCDEF1..HEAD git log ABCDEF1^..HEAD | list all commits from ABCDEF1 to HEAD ... including ABCDEF1 | |
svn blame FILE | git blame FILE | ... |
svn diff | less svn diff -rREV PATH | git diff git diff REV PATH | ... |
svn status | git status | ... |
svn revert PATH | git checkout PATH | ... |
svn add PATH | git add PATH | ... |
svn rm PATH | git rm PATH | ... |
svn mv PATH | git mv PATH | ... |
svn commit -m MMM | git commit -a -m MMM git push origin [BRANCHNAME] | commit recursively to local repository, then push to remote (origin); BRANCHNAME is optional if things are mapped correctly |
svn commit FILESPEC -m MMM | git add [FILESPEC] git commit -m MMM git push origin [BRANCHNAME] | same, but only a single file (need to add it if there isn't commit -a) |
branches | ||
svn copy URL/trunk URL/branch/BRANCHNAME | git branch BRANCHNAME | create a new branch |
git push origin localbranch:remotebranch | working on localbranch on my machine, but want to push to a new branch at github (seen on CodingTrain) | |
git push origin -u remotebranch | push from my active local branch to new remotebranch at github, and link them | |
svn switch ^/branches/BRANCHNAME | git checkout BRANCHNAME or git checkout -b BRANCHNAME origin/BRANCHNAME | switch working copy to the branch (the second keeps it in sync with the remote BRANCHNAME) |
git checkout -b BRANCHNAME git push -u origin BRANCHNAME | switch working copy to new branch, then push the new branch to the origin | |
svn merge ^/branches/BRANCHNAME | git merge BRANCHNAME | merge changes from BRANCHNAME into local |
svn list ./branches/ | git branch | list only local branches |
svn list ^/branches/ | git branch -r | list only remote branches |
svn list ./branches ^/branches/ | git branch -a | list local and remote branches |
git branch -vv | list branches with extra details; ones with "gone" should be pruned | |
git fetch -p git remote prune [-n] <name> git branch -D <branchname> | prune deleted remote branches from branch -r/-a list, where name is normally origin; -n is same as --dry-run | ; the branch -D may be needed to actually delete after being pruned|
git log BRANCHNAME --not main | list all commits for the given branch, without including any from the main branch | |
git configuration | ||
git config --global user.name VALUE git config --global user.email VALUE | configure username/email for all repos (omit VALUE to read) | |
git config user.name VALUE git config user.email VALUE | configure username/email for current repo to be different than the global setting (omit VALUE to read) | |
git config --global init.defaultBranch main | use 'main' instead of 'master'† | |
SVN_EDITOR=c:/usr/local/scripts/block++.bat | git config --global git config --global core.editor "c:/usr/local/scripts/block++.bat" | set editor for commit messages† |
git config remote.origin.prune true | automatically prune deleted remote branches | |
git config --list git config --list --global | list all configured options | |
misc | ||
svn:externals | git subtree merges | embed external repo links * |
git reset --soft ABC1234 git commit -m "..." git push -f origin | If you started at ABC1234, then did commits A1, B2, C3, D4, E5, this will "squash" them then do a force-push to get it to look like it went immediately from ABC1234 to E5A in a single commit instead of 5 commits. |
page look-and-feel inspired by lifehacker.me