todo-git
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| todo-git [2017/03/10 23:31] – [Renaming branches] dblume | todo-git [2022/02/04 15:02] (current) – removed dblume | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== git ====== | ||
| - | |||
| - | Make the clone at the remote repository. | ||
| - | |||
| - | < | ||
| - | git clone git@github.com: | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | git remote add upstream git:// | ||
| - | </ | ||
| - | |||
| - | Enter a comment for the commit. | ||
| - | < | ||
| - | git commit -a | ||
| - | </ | ||
| - | |||
| - | Double checking the alias names... | ||
| - | |||
| - | < | ||
| - | $ git remote -v | ||
| - | origin | ||
| - | origin | ||
| - | upstream | ||
| - | upstream | ||
| - | </ | ||
| - | |||
| - | The push that worked from within the local directory: | ||
| - | |||
| - | < | ||
| - | git push origin | ||
| - | </ | ||
| - | |||
| - | ===== Make a local clone of an existing remote project ===== | ||
| - | |||
| - | From the parent directory: | ||
| - | |||
| - | < | ||
| - | git clone https:// | ||
| - | cd python-interview | ||
| - | </ | ||
| - | |||
| - | ===== When it's time to commit ===== | ||
| - | |||
| - | **1.** Check which files are staged for commit. | ||
| - | |||
| - | < | ||
| - | git status | ||
| - | </ | ||
| - | |||
| - | **2.** Then, when you're ready to commit locally, | ||
| - | |||
| - | < | ||
| - | git commit -a -m "Some useful comment" | ||
| - | </ | ||
| - | |||
| - | **3.** When you're ready to push a local commit to a remote one... | ||
| - | |||
| - | < | ||
| - | git push -u origin master | ||
| - | </ | ||
| - | |||
| - | or | ||
| - | |||
| - | < | ||
| - | git push https:// | ||
| - | </ | ||
| - | |||
| - | ===== Creating a new remote repository from an existing local one ===== | ||
| - | |||
| - | I created hexbright-factory at [[https:// | ||
| - | |||
| - | < | ||
| - | touch README.md | ||
| - | git init | ||
| - | git add README.md | ||
| - | git commit -m "first commit" | ||
| - | git remote add origin https:// | ||
| - | git push -u origin master | ||
| - | </ | ||
| - | |||
| - | ===== Creating a new remote repository from an existing local one ===== | ||
| - | |||
| - | I created wine-tasting at [[https:// | ||
| - | |||
| - | < | ||
| - | ~$ mkdir wine-tasting | ||
| - | ~$ cd wine-tasting/ | ||
| - | wine-tasting$ vim README.md | ||
| - | wine-tasting$ vim LICENSE.txt | ||
| - | wine-tasting$ git init | ||
| - | wine-tasting$ git add README.md | ||
| - | wine-tasting$ git add LICENSE.txt | ||
| - | wine-tasting$ git add test.py | ||
| - | wine-tasting$ git add wine_allocator.py | ||
| - | wine-tasting$ git commit -m "first commit" | ||
| - | wine-tasting$ git remote add origin https:// | ||
| - | wine-tasting$ git push -u origin master | ||
| - | </ | ||
| - | |||
| - | ====== Renaming branches ====== | ||
| - | |||
| - | To rename a remote branch: | ||
| - | |||
| - | - Rename the local one. | ||
| - | - Push the deletion of the old name. | ||
| - | - Push the new name. | ||
| - | - git remote prune origin | ||
| - | |||
| - | When someone else renamed a remote branch: | ||
| - | |||
| - | <code bash> | ||
| - | $ git fetch --all # TODO investigate why fetch | ||
| - | $ git remote prune origin | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== Changing a local branch without regard to remote branch ==== | ||
| - | |||
| - | < | ||
| - | $ git checkout -b branch_name | ||
| - | Switched to a new branch ' | ||
| - | </ | ||
| - | |||
| - | That was the same as "git branch branch_name; | ||
| - | |||
| - | ==== Changing a local branch to a new remote branch ==== | ||
| - | |||
| - | This' | ||
| - | |||
| - | < | ||
| - | $ git checkout --track origin/ | ||
| - | </ | ||
| - | |||
| - | ==== Making the current local branch track a new remote branch ==== | ||
| - | |||
| - | < | ||
| - | $ git branch -u origin/ | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | ====== git at dlma.com ====== | ||
| - | |||
| - | I created a remote git repo at dlma like so: | ||
| - | |||
| - | At the server: | ||
| - | |||
| - | <code bash> | ||
| - | git$ mkdir testcode.git | ||
| - | git$ cd testcode.git/ | ||
| - | testcode.git$ git init --bare | ||
| - | </ | ||
| - | |||
| - | Then, at the local computer: | ||
| - | |||
| - | <code bash> | ||
| - | testcode$ git init | ||
| - | Initialized empty Git repository in / | ||
| - | testcode$ git add . | ||
| - | testcode$ git commit -m "first commit" | ||
| - | ... | ||
| - | testcode$ git remote add origin ssh:// | ||
| - | testcode$ git push origin master | ||
| - | </ | ||
| - | |||
| - | I could' | ||
| - | |||
todo-git.1489217508.txt.gz · Last modified: 2023/04/12 20:44 (external edit)