Skip to content

Commit

Permalink
beginners resources added
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanya Gupta committed Mar 24, 2018
1 parent 673a0c1 commit 4804b20
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
114 changes: 114 additions & 0 deletions docs/beginners.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!DOCTYPE html>
<html>
<title>Google Offline Navigator: An open source project built for Grow with Google </title>


<link rel="stylesheet" type="text/css" href="style.css">
<xmp theme="cerulean" style="display:none;">
If you came to this page, you have already made the first important step in taking on open source project. Everyone started off from where you are at present. It will get better.
These resources are written with the beginner in mind. Please open an issue if you think these resources can be improved<br>
<img id="inspiration" style="width:25%" src ="https://darcxed.files.wordpress.com/2011/10/while.jpg">
## How do I get started

### Set up
1. Install [git](https://git-scm.com/downloads) - note there are differences depending on whether you have a PC, Mac etc.
1. git config --global user.name "Tanya Gupta" to set up the user name
1. Confirm it is set up correctly git config --global user.name
1. git config --global user.email "[email protected]" Set up commit email address in Git
1. Confirm it is set up correctly git config --global user.email
1. If you want to "push" your changes without typing in your password each time read [this](https://github.com/tanyagupta/codeblogs/blob/development/githubHowTos/howto.md) upto "Getting Started" section
1. Most of your work with git will take place at your terminal. You will need to be familiar with terminal commands ([mac](https://github.com/0nn0/terminal-mac-cheatsheet) and with [basic Git commands](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet))
1. Create a directory where you will be working. `mkdir gwg` where gwg is the name of your directory.
1. `cd gwg` to go to the newly created directory
1. `git init` will initialize the repo
1. "Fork" the repo ![fork](https://camo.githubusercontent.com/9aa6c12b0a100ea4be6215ea84ea12556e4dc013/68747470733a2f2f68656c702e6769746875622e636f6d2f6173736574732f696d616765732f68656c702f7265706f7369746f72792f666f726b5f627574746f6e2e6a7067)
1. Now clone the open source proect you want to contribute to. In this case clone by typing `git clone https://github.com/TheDevPath/googleMaps-offline-navigator` This will create a directory called googleMaps-offline-navigator in your project directory
1. Your local repository consists of three "trees" maintained by git. The first one is your Working Directory which holds the actual files. The second one is the Index which acts as a staging area and finally the HEAD which points to the last commit you've made see [nice visual here](http://rogerdudler.github.io/git-guide/) under workflow
1. Now you have all the files you need an editor where you can edit the files (sort of like a Microsoft Word but for coding). There are a lot of [nice editors](https://medium.com/level-up-web/best-free-code-editors-for-web-developers-2837ccfd1d) out there. Pick [Atom](https://atom.io) if you are not sure what you want - it is a pretty safe choice.

### Your workflow
1. Your workflow (roughly) looks like this
- You "copy" or more correctly clone the original code (as above)
- Make changes to the code in your editor, test it out and make sure the changed code works
- Once you are done, you will use git and your terminal to "push" the changes that you make
2. If you are contributing to another repo you cannot generally just push your changes directly to the repo. Therefore you would typically push changes to your copy of the repo on Github and then issue what is called a "pull request" to the original repo so that they can consider the changes you are proposing. If they accept they will "merge" the changes into the original repo.

### Contributing
1. Create a new branch `git checkout -b newbranchname` to make your changes on
1. Make changes and commit
- Make changes to file(s) as needed
- Assuming only one file is changed, `git status` should show one file modified in red
- `git add filename` instead of filename use the file you have changed. For adding all files use `git add .`
- `Git status` check status, should show same file as modified in green
- `git commit -m 'some message that describes the change' `
- `git status`
- `git push origin newbranchname`
1. Set remote and origin are set correctly and issue pull request
- `git remote -v' to check origin and remote`. Usually you will only see the origin if you are just starting your setup. The origin is your github codebase and the upstream is where you are getting the codebase from (see additional information below for using https:

```
origin [email protected]:tanyagupta/codeblogs.git (fetch)
origin [email protected]:tanyagupta/codeblogs.git (push)
```
- Now add the upstream path

`git remote add upstream [email protected]:TheUserName/the-remote-file.git`

Note that you should only use add if you are setting it for the first time. If the upstream has already been set and you are changing it, do not use add as it will give you an error. In this situation, substitute `add` with`set-url`, the rest of the command is the same.

Now you should see something similar to the following when you `git remote -v`


```
origin [email protected]:tanyagupta/codeblogs.git (fetch)
origin [email protected]:tanyagupta/codeblogs.git (push)
upstream [email protected]:tanyagupta/codeblogs.git (fetch)
upstream [email protected]:tanyagupta/codeblogs.git (push)
```
- If you go away and come back and changes have occurred in the meanwhile, make sure you have the latest version. `git pull upstream development && git push` development is the name of the branch you want to pull from

- Issue pull request and clean up




#### Once the pull request is accepted and the proposed changes have been merged, you can take care of your own codebase and clean up

- Merge your changes into master and delete the branch you created
- `git checkout master` Switch to master
- `git merge newbranchname` This merges the changes to your master
- `git branch -d newbranchname` This deletes the old branch
- If needed delete remote branch `$ git push origin --delete newbranchname`

### Stash
The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy

``$ git stash``

See [link](https://www.atlassian.com/git/tutorials/git-stash) for more

### Commands and more resources
| Command | What it does |
| ------------- | ------------- |
| git remote -v | shows origin and remote |
| git status | shows files staged, commited or changed |
|git branch -d newbranchname|deletes a branch, -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in. its upstream branch. (You could also use -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status) |
|git pull upstream development && git push | pulls latest changes from upstream branch development and also pushes the changes to your github account|
|git remote rename oldname newname | renames remote [More](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes)
| git checkout branchname |Switches to an existing branch|
|git branch -a|See all branches|
|ls -a|Shows Hidden directories|
|git rebase master development| where development is the branch that needs to be aligned with master. Rebasing is tricky so check out this [reference](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)|
|git reset --hard master|when you are on development, use this command to abandon any changes made to branch development and just replicate what is on branch master|
|git stash|Saves uncommited changes for later use (will not do this for untracked or ignored files|
|git stash pop|Removes the changes saved in stash and reapplies them to the working copy|
|git stash apply|Keeps both the stash and also reapplies changes to working copy|
|git stash list| shows all your stashes|
|git branch -a|Shows all remote and local branches|
See [link](https://github.com/tanyagupta/codeblogs/blob/development/githubHowTos/howto.md) for additional commands and resources (scroll down to the end)


</xmp>

<script src="https://cdn.rawgit.com/arturadib/strapdown/gh-pages/v/0.2/strapdown.js"></script>
</html>
3 changes: 3 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
Not only that, contributing is a great way to get involved with social coding. We are excited to see what amazing contributions you will make, as well as how your contributions will benefit others.
Here is how you can [contribute](CONTRIBUTING.md) and here is how you can get [set up](README.md) with the code base

## Beginners
This project has a special section for those who are just starting out on their open source journey. Check it out [here](beginners.html) and open issues for any changes

## Learning Resources
This is where the team captures lessons learned, best practices and "gotchas" that may be of help to others - check it [out](learning.html)

Expand Down
6 changes: 6 additions & 0 deletions docs/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
.txt-cntr{
text-align: center;
}

#inspiration{
display: block;
height: 50px;
width: 50px;
}

0 comments on commit 4804b20

Please sign in to comment.