https://github.com/githubacountoffork/repositorytofork
Hit the Fork button. Once you click on the Fork button the repository would be forked to your github account.
https://github.com/yourgithubaccount/repositoryoffork
This fork would be the origin for you to push changes to the repository that you forked. Basically you are making changes to your local fork and then giving pull request to the original source where the actual repository is.
Clone the forked master repository from the github to your local development machine.
git clone https://github.com/yourgithubaccount/repositoryofforkAdd the remote upstream to say where to get the remote repository
git remote add upstream https://github.com/githubacountoffork/repositorytoforkVerify the new remote named 'upstream'. You should see both 'origin' and 'remote' pointing back to the server link.
git remote -vAs a best practice do not work on the local master, create a branch for every story or task
git branch branch-nameCheck the branch that you have created.
The * on the branch name indicates the current active branch.
git branchOn of the greatest feature of git from other repository is that you don't have multiple folders for different release of repositories like mainline, dev, release 1 etc. You just switch between branches using the same physical repository.
The downside is that you can work on only one branch at a time. We need to ensure that we are in the right branch all the time. To switch to any given branch use the following command
git checkout branch-nameWork on the files, using IDE of your choice, to check which files are modified issue
git statusWhen you are done doing the changes, add those files to git and issue a commit before working on new files for committing.
git add .To selectively add the files, go to the individual folders run the add command using the file name or folder name.
Do a Git status and check the message about 'pending commit'. The add command has only 'staged' the changes. The changes are not committed yet.
git statusThe next step is to commit the change using the following changes.
Commit will take all the 'staged' files and commit to your local branch.
git commit -m 'commit message detailing the changes.'Check status and make sure changes are committed.
git statusPush these changes to your fork, if the branch name is not present, this branch is automatically created
git push origin 'branch-name'Now log on the github.com website.
From the drop down select the branch name that you just 'pushed'
Create a pull request targeted to the Origin repository
This will send a pull request to the reviewer who can review and merge the changes.
After the pull request is merged to the main master, we have the option to Delete a branch. Remember we have a local copy and a remote copy. So we have to delete both. Sometimes the remote fork branch copy can be deleted by the Pull Request taker. In this case there is no need to delete the remote branch on the fork.
To delete the local branch, move to the master branch before deleting your local branch
git checkout masterForce delete the local branch
git branch -D branch-nameIf the branch is not deleted by the Pull Request (PR) on the Remote Branch
git push origin branch-nameOnce manual step with this approach is that you need to synchronize the remote repository to your fork. This is not done automatically as sometimes people just want to work on that version of the fork only. This is not enforced by Github.com
Get all changes from remote
IMPORTANT: make sure that you have the correct working branch before you issue this command else your would replace your other branches and conflicts can occur.
git branchPull changes from the remote upstream branch
git pull upstream masterPush this changes to your local fork branch
git push origin master
No comments:
Post a Comment