Difference between revisions of "Draft: Github development process"
Foxfirefey (Talk | contribs) (→Deleting branches: add branch delete for Github) |
Foxfirefey (Talk | contribs) (fill in some more details) |
||
Line 26: | Line 26: | ||
=== Viewing changes === | === Viewing changes === | ||
− | + | To get an overview of which files have changed, which files are included in your next commit, and what new files exist, use: | |
git status | git status | ||
− | + | To get a line by line description of all of the changes, use: | |
git diff | git diff | ||
+ | |||
+ | When you want the changes you've made to a file you have to be included in your next commit, use <code>git add</code>: | ||
+ | |||
+ | git add FILE | ||
+ | |||
+ | If you make more changes to that file, you will have to add it again to have the new changes included. | ||
=== Stashing and unstashing === | === Stashing and unstashing === | ||
− | + | Sometimes you may have changes you are not ready to commit yet, but need to stow away while doing tasks like merging. <code>git stash</code> can be useful for this. | |
+ | |||
+ | To save a bunch of changes: | ||
git stash | git stash | ||
− | + | To put the changes back: | |
git stash pop | git stash pop | ||
Line 56: | Line 64: | ||
=== Committing changes === | === Committing changes === | ||
− | When committing, it's a good idea to make sure your develop branch is up to date with the Dreamwidth's version, and that your current branch is merged with those changes. See [Dev Maintenance] for instructions on that. Once you are satisfied | + | When committing, it's a good idea to make sure your develop branch is up to date with the Dreamwidth's version, and that your current branch is merged with those changes. See [Dev Maintenance] for instructions on that. Then review your changes with <code>git status</code> and <code>git diff</code>, using <code>git add</code> to add the changes you want to commit. Once you are satisfied that these changes are the ones you want to make, you can use: |
− | git commit | + | git commit |
+ | |||
+ | This will open up the command line editor specified in your config. (You can change this with instructions in [[Git settings]].) Write up a good description of the changes included in this commit. | ||
{{Expand|text=Writing commit messages: best practices.}} | {{Expand|text=Writing commit messages: best practices.}} | ||
+ | |||
+ | If you are making a commit that only needs a short explanation, you can use the -m option: | ||
+ | |||
+ | git commit -m "This describes the change that I just made." | ||
=== Pushing your changes to your repository on Github === | === Pushing your changes to your repository on Github === | ||
+ | |||
+ | After committing your changes, you need to push them to your repository on Github. You can do this with: | ||
git push origin BRANCHNAME | git push origin BRANCHNAME | ||
Line 100: | Line 116: | ||
git push origin --delete <branchName> | git push origin --delete <branchName> | ||
+ | |||
+ | [[Category: Development]] | ||
+ | [[Category: Git]] |
Revision as of 05:43, 26 August 2012
This page is a draft page to document how development with Github works.
Contents
Starting a new branch
Before starting a new branch, wrap up any changes you are making by either stashing them or committing them to the current branch you are on.To start a new branch, use the branch command. You will want a descriptive name you can keep track of--for instance, the bug number you are working on. Examples:
mw@memewidth:~/dw$ git branch Bug4335/admintt
Then, to switch to this branch, use the checkout command:
mw@memewidth:~/dw$ git checkout Bug4335/admintt Switched to branch 'Bug4335/admintt'
Managing changes
Before doing any changes to a branch, make sure you have that branch checked out. You can check this with:
git branch
It will list the branches and put an asterisk next to the one you currently have checked out. If it's not, run:
git checkout BRANCHNAME
Viewing changes
To get an overview of which files have changed, which files are included in your next commit, and what new files exist, use:
git status
To get a line by line description of all of the changes, use:
git diff
When you want the changes you've made to a file you have to be included in your next commit, use git add
:
git add FILE
If you make more changes to that file, you will have to add it again to have the new changes included.
Stashing and unstashing
Sometimes you may have changes you are not ready to commit yet, but need to stow away while doing tasks like merging. git stash
can be useful for this.
To save a bunch of changes:
git stash
To put the changes back:
git stash pop
Undoing changes
Undo changes to one file:
git reset ????FILLIN????
The nuclear option:
git reset --hard
Committing changes
When committing, it's a good idea to make sure your develop branch is up to date with the Dreamwidth's version, and that your current branch is merged with those changes. See [Dev Maintenance] for instructions on that. Then review your changes with git status
and git diff
, using git add
to add the changes you want to commit. Once you are satisfied that these changes are the ones you want to make, you can use:
git commit
This will open up the command line editor specified in your config. (You can change this with instructions in Git settings.) Write up a good description of the changes included in this commit.
If you are making a commit that only needs a short explanation, you can use the -m option:
git commit -m "This describes the change that I just made."
Pushing your changes to your repository on Github
After committing your changes, you need to push them to your repository on Github. You can do this with:
git push origin BRANCHNAME
Making a pull request
Before making a pull request, make sure that the develop
branch is up to date and you have merged the branch you are developing with it. (See Dev Maintenance for help with this.)
Then, once everything is all up to date, go to your version of the repository (dw-free or dw-nonfree) that you want to send upstream. By default they should be at:
https://github.com/USERNAME/dw-free https://github.com/USERNAME/dw-nonfree
These repositories are separate, so if you have made changes to both of them, you will have to submit pull requests for both of them.
Find the "Pull Request" button (by "Unwatch") under the top toolbar. Click it and you will be brought to the pull request page.
Ideally, the initial page should say something like "Oops! dreamwidth:develop is already up-to-date with USERNAME:develop Try a different branch?" That's good--that means that your develop
branch is up to date with Dreamwidth's!
Find the "head branch" drop down and select the branch you want to submit a pull request for.
When this is done, press the "Send pull request" button.
Deleting branches
You might create a branch by mistake, or have your changes pulled into the main develop branch on Dreamwidth. To delete the branch locally, use the command:
git branch -D BRANCHNAME
If the branch is also on your Github, you can delete it like this:
git push origin --delete <branchName>