Skip to content

commit your changes 3

Kitty Hurley edited this page Jul 26, 2015 · 5 revisions

##Commit Your Changes and Contribute Them Back to the Project Up to this point, a file in the local repo folder has been edited and saved, but those changes have not been committed to the local repo.

###10. Check the status of your local repo

  • In your shell, type git status to, well, check on the status of the repo. It should return:
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   js/places.geojson

no changes added to commit (use "git add" and/or "git commit -a")

We haven't added or committed the changes on our edited file to our local repo, but Git knows that the file that we edited has changed.

  • The first step in committing the changes is staging the file using git add. In this case:

git add js/places.geojson

  • Check the status again with git status and you should see:
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   js/places.geojson
  • Now, you can commit the staged changes to your local repo using git commit. We also use the -m option to add a short message that describes the commit.

git commit -m "Added my favorite local spot"

  • You can also add in a subject and additional message when running a commit. To do so use the following:

git commit -m "Added my favorite local spots" -m "Added 4 restaurants: Fogo de Chao, Butcher and the Boar, 112 Eatery, and Cossetta's."

Returns

[master fe34ccd] Added my favorite local spot
 1 file changed, 19 insertions(+), 1 deletion(-)
  • Check the status again with git status and you should see:
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

###11. Push changes back to your Github fork repo The next step in contributing your changes back to the official project repo is pushing your commits back to the fork of the official project repo that you created on Github. We do this by typing: git push origin/master

Which should return something like:

Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 533 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
To https://github.com/YOUR_NAME/nacis2015-map.git
   b7ad7ea..fe34ccd  master -> master

Remember that 'origin' is the name of your forked repo on GitHub. And 'master' is the branch that you have been working on. We have been using a very simple model where you commit your changes directly to the master branch.

You can then go to https://github.com/YOUR_NAME/nacis2015-map and refresh the page. You should see your new commits there.

###12. Create a pull request Most projects don't let everyone commit directly to the official project repository. Changes are submitted to the project via GitHub pull requests, and there are usually a few people who have rights to review pull requests, deal with any merge code conflicts, and then merge the changes in.

Now that your commits are in your GitHub fork, on that page, click the link on the right that says 'Pull Requests'. You will get to a page that shows any existing pull requests that you have created (which shouldn't be any). Click the green, 'New Pull Request' button in the upper right part of the page.

You will see a nice interface for looking at the 'diff' or changes between the current files in the official repo and the changes that you have committed. If everything looks good, hit the green, 'Create Pull Request' button.

Previous Page: Add a Datapoint

Clone this wiki locally