Git: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
=== TASKS === | === TASKS === | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! New shared central bare repo | ||
|- | |- | ||
| On central server (aka bitpost): | | On central server (aka bitpost): | ||
Line 72: | Line 72: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Merging conflicts after diverging | ||
|- | |- | ||
| Revert local changes in a file to HEAD | | Revert local changes in a file to HEAD | ||
Line 80: | Line 80: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Create and push a feature branch | ||
|- | |- | ||
| This will move recent commits AND uncommitted changes into a new branch (but you probably want to finish by cleaning out commits from starting branch, and repulling after you merge the feature). | | This will move recent commits AND uncommitted changes into a new branch (but you probably want to finish by cleaning out commits from starting branch, and repulling after you merge the feature). | ||
Line 178: | Line 178: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Create new branch on server, pull to client | ||
|- | |- | ||
| | | | ||
Line 197: | Line 197: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Merge changes in a single file | ||
|- | |- | ||
| Explanation is [https://stackoverflow.com/a/11593308/717274 here]. | | Explanation is [https://stackoverflow.com/a/11593308/717274 here]. | ||
Line 204: | Line 204: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Remove old branches | ||
|- | |- | ||
| Explanation is [https://stackoverflow.com/a/23961231/717274 here]. | | Explanation is [https://stackoverflow.com/a/23961231/717274 here]. | ||
Line 232: | Line 232: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Pull when untracked files are in the way | ||
|- | |- | ||
| This will pull, forcing untracked files to be overwritten by newly tracked ones in the repo: | | This will pull, forcing untracked files to be overwritten by newly tracked ones in the repo: | ||
Line 239: | Line 239: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Create new branch when untracked files are in the way | ||
|- | |- | ||
| | | | ||
Line 257: | Line 257: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Recreate repo | ||
|- | |- | ||
| | | | ||
Line 268: | Line 268: | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Connect to origin after the fact | ||
|- | |- | ||
| | | | ||
Line 282: | Line 282: | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Ignore local and remote changes to a file | ||
|- | |- | ||
| This is helpful for conf files that need local-specific modifications that shouldn't be pushed. You have to toggle it on/off as needed to get updates! See [http://stackoverflow.com/questions/4348590/how-can-i-make-git-ignore-future-revisions-to-a-file/39776107#39776107 my SO answer]. | | This is helpful for conf files that need local-specific modifications that shouldn't be pushed. You have to toggle it on/off as needed to get updates! See [http://stackoverflow.com/questions/4348590/how-can-i-make-git-ignore-future-revisions-to-a-file/39776107#39776107 my SO answer]. | ||
Line 301: | Line 301: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Changing branches in a project with submodules | ||
|- | |- | ||
| | | | ||
Line 308: | Line 308: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Hard-reset a misbehaving submodule to parent commit version | ||
|- | |- | ||
| | | | ||
Line 317: | Line 317: | ||
=== CONFIGURATION === | === CONFIGURATION === | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Visual difftool and mergetool setup | ||
|- | |- | ||
| Meld is purdy, let's kick its tires. Hope it actually works... | | Meld is purdy, let's kick its tires. Hope it actually works... | ||
Line 362: | Line 362: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Convert to a bare repo | ||
|- | |- | ||
| Start with a normal git repo via [git init]; add your files, get it all set up. Then do this: | | Start with a normal git repo via [git init]; add your files, get it all set up. Then do this: | ||
Line 379: | Line 379: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Convert bare to a mirror of remote (github, facebook, etc) | ||
|- | |- | ||
| You need a bare mirror repo if you want to take someone else's repo and create your own bare to work from. | | You need a bare mirror repo if you want to take someone else's repo and create your own bare to work from. | ||
Line 391: | Line 391: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Create merge-to command | ||
|- | |- | ||
| Add this handy alias command to all git repos' .config file... | | Add this handy alias command to all git repos' .config file... | ||
Line 399: | Line 399: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Fix github diverge from local bare repo following README.md edit | ||
|- | |- | ||
| Yes editing the README.md file on github will FUCK UP your downstream bare repo if you meanwhile push to it before pulling. | | Yes editing the README.md file on github will FUCK UP your downstream bare repo if you meanwhile push to it before pulling. | ||
Line 416: | Line 416: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Windows configure notepad++ editor | ||
|- | |- | ||
| | | | ||
Line 422: | Line 422: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Fix push behavior - ONLY PUSH CURRENT doh | ||
|- | |- | ||
| | | | ||
Line 428: | Line 428: | ||
|} | |} | ||
{| class="mw-collapsible mw-collapsed wikitable" | {| class="mw-collapsible mw-collapsed wikitable" | ||
! | ! Multiple upstreams | ||
|- | |- | ||
| Use this to cause AUTOMATIC push/pull to a second origin: | | Use this to cause AUTOMATIC push/pull to a second origin: |
Revision as of 22:59, 20 January 2022
TASKS
ExpandNew shared central bare repo |
---|
Expandcreate shared central repo for existing code |
---|
ExpandSet default branch of a bare repo |
---|
Expandgitflow |
---|
ExpandFetch a branch from remote without checking it out |
---|
ExpandPush any branch from bare to origin |
---|
ExpandMerging conflicts after diverging |
---|
ExpandCreate and push a feature branch |
---|
Expandgetting upstream commits into your GitLab GITFLOW fork |
---|
Expandgetting upstream commits into your GitLab fork |
---|
Expandgetting upstream commits into your GitHub fork |
---|
ExpandClone a bare repo (eg github, gitlab, bb) into a bare repo |
---|
ExpandCreate new branch on server, pull to client |
---|
ExpandMerge changes in a single file |
---|
ExpandRemove old branches |
---|
ExpandWork with two local repos |
---|
ExpandPull when untracked files are in the way |
---|
ExpandCreate new branch when untracked files are in the way |
---|
ExpandRecreate repo |
---|
ExpandConnect to origin after the fact |
---|
ExpandIgnore local and remote changes to a file |
---|
ExpandChanging branches in a project with submodules |
---|
ExpandHard-reset a misbehaving submodule to parent commit version |
---|
CONFIGURATION
ExpandVisual difftool and mergetool setup |
---|
ExpandConvert to a bare repo |
---|
ExpandConvert bare to a mirror of remote (github, facebook, etc) |
---|
ExpandCreate merge-to command |
---|
ExpandFix github diverge from local bare repo following README.md edit |
---|
ExpandWindows configure notepad++ editor |
---|
ExpandFix push behavior - ONLY PUSH CURRENT doh |
---|
ExpandMultiple upstreams |
---|
Git branching strategies
Simplified Gitflow
This is awesome, tight, and well-capable of handling any app with a single primary release (like a website).
RELEASE TAG o----------------------------o-----------------o------------o------> MASTER \ / \ \----------/ HOTFIX \ / \ \ \----------------------/ \--------------------o-----o------> DEVELOP \ / \----------------/ FEATURE
Gitflow
I was a die-hard believer in gitflow for a while. It's very capable. Too capable. You MIGHT need it if you are supporting multiple versions in production... but in all my cases, it is overkill, compared to Simplified Gitflow. The classic diagram, originally from here...