Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tips:git [2016/10/06 16:35] – [new remote branch] scipio | tips:git [2019/03/13 09:30] (current) – [apache git] scipio | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== GIT ====== | ====== GIT ====== | ||
+ | |||
+ | ===== credentials | ||
+ | |||
+ | <file ini ~/ | ||
+ | machine git.csgalileo.org | ||
+ | login blabla | ||
+ | password blabla | ||
+ | </ | ||
+ | |||
+ | <file ini ~/ | ||
+ | [user] | ||
+ | name = Stefano Scipioni | ||
+ | email = blabla | ||
+ | [core] | ||
+ | autocrlf = input | ||
+ | #safecrlf = true | ||
+ | editor = vim | ||
+ | [http] | ||
+ | sslverify = false | ||
+ | [alias] | ||
+ | co = checkout | ||
+ | ci = commit | ||
+ | st = status | ||
+ | br = branch | ||
+ | hist = log --pretty=format: | ||
+ | type = cat-file -t | ||
+ | dump = cat-file -p | ||
+ | [push] | ||
+ | default = simple | ||
+ | [color] | ||
+ | ui = auto | ||
+ | </ | ||
+ | |||
===== New repo ===== | ===== New repo ===== | ||
Line 13: | Line 46: | ||
</ | </ | ||
+ | ===== change origin ===== | ||
+ | |||
+ | <code bash> | ||
+ | git remote -v | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | git remote set-url origin http:// | ||
+ | </ | ||
+ | |||
+ | check origin | ||
+ | <code bash> | ||
+ | git remote show origin | ||
+ | </ | ||
+ | |||
+ | if prune needed (on server restart apache if dav is used) | ||
+ | <code bash> | ||
+ | git remote prune origin | ||
+ | </ | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | git push --set-upstream origin master | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== create branch with current changes ===== | ||
+ | |||
+ | < | ||
+ | git checkout -b newBranch | ||
+ | </ | ||
+ | |||
+ | ===== tag ===== | ||
+ | |||
+ | < | ||
+ | git tag -a v1.1 -m " | ||
+ | git push origin v1.1 | ||
+ | </ | ||
===== new remote branch ===== | ===== new remote branch ===== | ||
Line 25: | Line 98: | ||
create or update remotly | create or update remotly | ||
< | < | ||
- | git push origin [name_of_branch] | + | git push --set-upstream |
</ | </ | ||
Line 35: | Line 108: | ||
fetch remote branches | fetch remote branches | ||
< | < | ||
- | git pull origin [name_of_branch] | + | git checkout -b [branch] |
+ | </ | ||
+ | |||
+ | ===== delete remote branch ===== | ||
+ | |||
+ | <code bash> | ||
+ | git push origin --delete [branch] | ||
+ | |||
+ | # and locally | ||
+ | git branch -d [branch] | ||
+ | </ | ||
+ | |||
+ | ===== rename branch (local and remote) ===== | ||
+ | |||
+ | |||
+ | < | ||
+ | git branch -m new-name | ||
+ | |||
+ | # Delete the old-name remote branch and push the new-name local branch. | ||
+ | git push origin :old-name new-name | ||
+ | |||
+ | # Reset the upstream branch for the new-name local branch. | ||
+ | git push origin -u new-name | ||
+ | </ | ||
+ | ===== Preserve specific files while merging ===== | ||
+ | |||
+ | start by defining a merge driver that would always favor our current version of the file | ||
+ | < | ||
+ | git config --global merge.ours.driver true | ||
+ | </ | ||
+ | |||
+ | into repo mark examplefile.json to use that driver instead of the standard one: | ||
+ | < | ||
+ | echo ' | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== integrate changes from one branch into another branch ===== | ||
+ | |||
+ | ==== merging ==== | ||
+ | |||
+ | from feature branch to master | ||
+ | <code bash> | ||
+ | git checkout feature | ||
+ | git merge master | ||
+ | </ | ||
+ | |||
+ | ==== or rebasing ==== | ||
+ | |||
+ | <code bash> | ||
+ | git checkout feature | ||
+ | git rebase -i master | ||
+ | |||
+ | # if remote feature is present force push on origin | ||
+ | git push --force origin feature | ||
+ | </ | ||
+ | |||
+ | ==== rebase remote branch (or original fork) with local branch ==== | ||
+ | |||
+ | add forked repo if none (git remote -v) | ||
+ | < | ||
+ | git remote add upstream https:// | ||
+ | </ | ||
+ | |||
+ | rebase remote on master | ||
+ | < | ||
+ | git fetch upstream | ||
+ | git checkout master | ||
+ | git merge upstream/ | ||
+ | git push | ||
+ | </ | ||
+ | ==== merge specific commit from branch to another ==== | ||
+ | |||
+ | <code bash> | ||
+ | git co < | ||
+ | git cherry-pick < | ||
+ | </ | ||
+ | |||
+ | ===== Home Assistant ===== | ||
+ | |||
+ | <code bash> | ||
+ | git clone https:// | ||
+ | cd home-assistant | ||
+ | git remote add upstream https:// | ||
+ | git pull upstream dev | ||
+ | </ | ||
+ | |||
+ | ===== apache git ===== | ||
+ | |||
+ | <code bash> | ||
+ | apt install apache2 | ||
+ | a2enmod dav_lock dav dav_fs macro | ||
+ | systemctl restart apache2 | ||
+ | </ | ||
+ | |||
+ | ===== submodule ===== | ||
+ | |||
+ | < | ||
+ | cd < | ||
+ | git checkout master | ||
+ | git branch -u origin/ | ||
+ | cd < | ||
+ | git config -f .gitmodules submodule.< | ||
</ | </ |