Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git [2024/02/28 17:46] – mgupton | git [2024/12/13 12:37] (current) – [Branches] mgupton | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======Git====== | + | ======git====== |
| A general guide for the distributed version control system Git. | A general guide for the distributed version control system Git. | ||
| Line 11: | Line 11: | ||
| git config --global user.email your@email.com | git config --global user.email your@email.com | ||
| git config --global core.excludesFile ~/ | git config --global core.excludesFile ~/ | ||
| + | git config --global init.defaultBranch main | ||
| </ | </ | ||
| Line 25: | Line 26: | ||
| Since a project that is just starting tends to be rudimentary it makes sense to initially create the repo with an empty master branch and then immediately create a //working// branch where the initial work will begin. Once the project gets further along and hits certain milestones the changes can be merged into the master branch. | Since a project that is just starting tends to be rudimentary it makes sense to initially create the repo with an empty master branch and then immediately create a //working// branch where the initial work will begin. Once the project gets further along and hits certain milestones the changes can be merged into the master branch. | ||
| - | * '' | + | * '' |
| Below is an example using Powershell to only run commands if there is not an existing Git repo configured. | Below is an example using Powershell to only run commands if there is not an existing Git repo configured. | ||
| Line 121: | Line 122: | ||
| ====== Branches ====== | ====== Branches ====== | ||
| + | * Checkout the branch the new branch is based on | ||
| + | * Then create branch | ||
| + | <code bash> | ||
| + | git branch <new branch name> | ||
| + | </ | ||
| + | * Create a ranch and check it out in one command | ||
| <code bash> | <code bash> | ||
| git checkout -b <new branch name> | git checkout -b <new branch name> | ||
| Line 126: | Line 133: | ||
| === Deleting Branches === | === Deleting Branches === | ||
| + | * Delete remote branch, if it exists | ||
| + | * Then delete the local branch | ||
| + | <code bash> | ||
| + | git push -d < | ||
| + | git branch -d <branch name> | ||
| + | </ | ||
| + | |||
| + | To force delete an unmerged branch | ||
| <code bash> | <code bash> | ||
| - | git push -d <remote_name> | + | git branch |
| - | git branch | + | |
| </ | </ | ||