#format wiki #language en = Git = * [[Git/Squash]] * Linux distributed version control. * Notes on using and setting up on Ubuntu. * Links [[https://help.ubuntu.com/lts/serverguide/git.html]] * [[Git/Tags]] == How to setup GIT private server == 1. Log into server, create git account, set it to use git-shell (no login), add .ssh/authorized keys for access with no password. 1. Create repo with $ '''git init --bare repository''' 1. On client edit * --bare can't be used * Setup .ssh/config, see example if using port, and can even use specific port. {{{ Host githost HostName git.host.de Port 4019 User git }}} 1. On client pc clone with $ '''git clone githost:repository''' 1. #(edit some files 1. '''git commit -a''' # Commit all changes to the local version of the repository 1. '''git push origin master''' # Push changes to the server's version of the repository == Nice Git prompt in Linux bash == * https://github.com/magicmonty/bash-git-prompt == Git submodule == * Home dir add code as seperate submodule git 1. on server # sudo -u git git init --bare !NewRepo 2. on pc code$ git submodule add git@git.server:!NewRepo === Submodule, with github.com https token === 1. In github.com, under usersettings -> developer -> generate token to be uses in place of pwd. * then with token= {{{ git submodule add https://my2022token:@https://github.com//.git }}} == Cleanup local branches already merged into Master == 1. Check what has not been merged with {{{ git branch --no-merged }}} 2. Delete branch {{{ git branch -d xxx }}} *. All in one {{{ git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d }}} == Manage homedir on new server from existing git repo == * Setup repo, with no-checkout {{{ git clone --depth 2 --no-checkout repo-to-clone gittemp mv gittemp/.git ~ rmdir gittemp }}} * Create a branch to keep current files local {{{ git branch original_201802 git checkout original_201802 git add . git commit }}} * switch back to main branch {{{ git checkout dev }}} * Merge original file back into dev if required. {{{ git merge original-201802 }}} == Working with github and upstream git repos == * View with $ git remote show {{{ $ git remote show origin upstream }}} * normally origin should point to your repo, clone possibly of upstream project e.g. {{{ $ git remote show upstream * remote upstream Fetch URL: git@github.com:boltgolt/howdy.git Push URL: git@github.com:boltgolt/howdy.git }}} * To sync latest upstream changes, merge into local master and possibly push back up to your origin e.g. {{{ git pull upstream git merge upstream/master ##Commit message git push }}} ==== Create branch based on upstream but pushed to my forked origin ==== * working on github, want to create branch in my forked origin, but based of upstream/master for a fix i want to push/merge to upstream. {{{ $ git remote origin upstream $ git fetch --all --tag Fetching origin Fetching upstream $ checkout -b fix#733-myBranch $ git reset --hard upstream/master $ git push --set-upstream origin fix#733-myBranch }}} ... ---- CategoryLinux