Note the -b option is used to specify a particular branch you want to work on in the project. You can verify the branch the local repository is pointing to by
1
git branch
The repository created locally by the clone points to the fork which was created by you on GitHub
You would also want to pull in all the changes happening in the project repository like changes from other contributers
Inorder to be able to pull the changes, set “upstream” to point to the project repository. CD to your local repository and issue the following command.
You can verify the “origin” and the “upstream” repositories your local repository is pointing to by issuing the following command
1
git remote -v
Inorder to update your local repository with any changes in the project repository, issue the following command
1
git pull upstream
Git wll perform automerge of changes where possible and if there are any conflicts they need to be resolved manually
Make the changes you wish to make to the project repository on your local machine and once satisfied follow these steps
Perform a pull upstream to make sure that your repository is upto date with project repository
1
git pull upstream
Commit all your changes to the local respository. This step will ask to enter comments about the change etc.
1
git commit -a
Push the changes to GitHub which will update the fork you had created initially. This step will prompt for your GitHub user-id and password
1
git push -u branch-name
You can verify that the changes are on your fork by browsing the changed components through GitHub web interface
Once satisfied with your changes, you can make a pull request using the pull request icon on the GitHub web interface
If the project owner is fine with the changes, the changes will get merged into the project repository. Then the changes will be available for everyone to use.
Few other useful commands
1
git stash
This will revert back all the changes made in the local repository
1
git rebase -i HEAD~n
Where n is a number and this will help in merging multiple commits into fewer so that the change history is much cleaner.
- This is a very quick summary of steps. Git documents provide details, options and other useful commands which you may want to look at