Differences
This shows you the differences between two versions of the page.
training:everyday_git_usage [2016/09/21 20:02] kluong [Notes] |
training:everyday_git_usage [2021/09/19 21:59] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Everyday Git Usage ====== | ||
- | |||
- | This page describes a very simple git workflow that can be used with most projects. | ||
- | |||
- | ===== Steps ===== | ||
- | |||
- | **Clone the repository**\\ | ||
- | git clone [email protected]:some-user/some-repo.git\\ | ||
- | |||
- | **Create a branch**\\ | ||
- | git checkout -b branch_name\\ | ||
- | -//Name your branch something descriptive: test-sampler, add-ga-comments//\\ | ||
- | |||
- | |||
- | **Update from the remote master**\\ | ||
- | //(Do this often if you're working on a branch for a while)\\ | ||
- | //git fetch\\ | ||
- | git rebase origin/master\\ | ||
- | |||
- | |||
- | **Committing your changes**\\ | ||
- | git add filenames.c \\ | ||
- | git commit\\ | ||
- | |||
- | **In case you forgot to add something to your commit**\\ | ||
- | git add filenames.c \\ | ||
- | git commit --amend\\ | ||
- | |||
- | **Submit a pull request on github**\\ | ||
- | git push origin branch name\\ | ||
- | - Go to the github repository, click on 'branches', and click on "new pull request"\\ | ||
- | - Have someone review your code. If new changes need to be made, make them.\\ | ||
- | - Click on 'squash and merge' | ||
- | |||
- | **Switch back to the master branch and update**\\ | ||
- | git checkout master\\ | ||
- | git fetch\\ | ||
- | git rebase origin/master | ||
- | |||
- | |||
- | |||
- | ===== Definitions ===== | ||
- | **git clone** - Clone a repository into a new directory. [[ https://git-scm.com/docs/git-clone | Details ]]\\ | ||
- | **git fetch** - Download objects and refs from another repository. [[https://git-scm.com/docs/git-fetch | details ]] \\ | ||
- | **git rebase** - Reapply commits on top of another base tip. [[https://git-scm.com/docs/git-rebase | Details ]] \\ | ||
- | **git add ** - Add file contents to the index [[https://git-scm.com/docs/git-add | Details ]] \\ | ||
- | **git commit** - Record changes to the repository. [[https://git-scm.com/docs/git-commit | Details ]] \\ | ||
- | **git push ** - Update remote refs along with associated objects. [[https://git-scm.com/docs/git-push | Details ]]\\ | ||
- | |||
- | |||
- | ===== Notes ===== | ||
- | |||
- | [0] Read the git output - it's normally pretty useful and will tell you what to do. | ||
- | |||
- | [1] We use rebasing to keep the history linear and clean. By doing this, we can make sure that every commit is well documented; this also has the added advantage of making code reviews easier as well. | ||
- | |||
- | |||