How to Upload to Github to Collaborate
The Ultimate Github Collaboration Guide
This is just 1 of many ways to interact on a project using GitHub. Merely it'southward one I would suggest if you're just starting out working with a team and haven't established a git flow yet or know where to start in establishing one.
Step ane: Initialize a New Project
Create a new project/directory from the command line
$ rails new github_guide
Go to Github and click the '+' push button in the rop right corner and select 'New Repository'.
Then fill up out the Repository proper name and the Clarification fields. Go along information technology public, and do not "Initialize this repository with a README". Don't change anything else. Click "Create repository".
Side by side y'all'll encounter the setup page. These are the instructions for connecting the Repo you but created in Github (Remote) to the directory yous created in your terminal (Local).
Paste the lines in the red box line by line starting with "repeat…" into the terminal while you're cd'ed into the directory y'all just created locally. Your terminal should look like this when you're done:
This adds a '.git' binder to your repo, connects you to your remote Github Repo and also gives you a '.gitignore' file.
And if you go to your Github Repo page, you'll see the ReadMe that y'all intialized with and the reference to the first commit you fabricated.
Now permit's get this Repo up to appointment. Go back to your final and git add, git commit, and git push button:
$ git add . $ git commit -m "2nd commit" $ git button
Now check out your repo. It should take all the files you created your local directory with along with a new commit id (9c2e2f6):
You're initialized and ready to start working!
Footstep 2: Setup Your Team
You're a team actor, so you're going to need to add your team to your repo so they can collaborate. Once your team is added as collaborators they'll be able to push button, merge, and a ton of other subversive things so make sure you're simply adding your teammates.
Click on the "Settings" tab of your rep, and then "Collaborators" then search for Github users and add them by clicking "Add Collaborator":
They'll receive an email letting them know you added them and will be listed as a collaborator.
If y'all're a collaborator, get to the Github Repo page, Git Clone the projection, and cd into the directory. Don't fork it! Forking volition re-create it in a new Repo to your Github page, but you don't want that — y'all want to interact on the aforementioned Github Repo with your teammates.
$ git clone git@github.com:MinesJA/github_guide.git $ cd github_guide/
And now you lot're fix to interact!
Step iii: Collaborating
When you're using git to work on the same project with multiple people, there'due south one primal rule you must follow:
THE Master Co-operative SHOULD ALWAYS Exist DEPLOYABLE
The way to go on Chief deployable is to create new branches for new features and merge them into Master when they're completed. Hither'due south how that works.
Step 3a: Branches
To start, branches should always represent features. For case, if yous desire to add together the ability for a user to login you lot should probably create a branch called "user_authentication" and in that branch you should only update what you need to to enable a user to login.
It's besides important when collaborating that your squad picks features that don't have overlapping code. For example, y'all shouldn't exist working on a "user_login" branch at the same fourth dimension that your teammate is working on a "user_logout" branch because the chances that you lot're working on the same files and are writing overlapping code are very high.
Then let's say you want to create the User model. In your terminal create a new branch:
$ git co -b create_user
"co" is short for "checkout" which is used to switch between branches. Adding the "-b" and a proper noun at the end creates a new branch and so moves into that new branch for u.s.a..
Yous should be able to verify this with the command:
$ git branch
Which should produce:
You're now in your new branch and can commencement coding abroad.
Notation: As a general rule, you should git add ofttimes and git commit when you cease something that allows your code to work (ends up being a couple times an hour). For example, when y'all stop a method and the lawmaking base works, git commit like so:
$ git commit -m "Added function to allow Users to say 'Hello World'"
Step 3b: Submitting Pull Requests
Your team spent all day and night working on their divide features in their various branches. They come dorsum the adjacent day with their completed features and want to merge them back into Master to exist deployed.
Determining your Git Flow is a huge part of working in a team, but here's one Git Menses y'all could adopt for at present:
First, determine who's going to be in charge of handling merging. The less people acting independently on merging the better so for a squad of four it would probably behoove you to have ane official "Reviewer" or "Merge Principal".
Side by side, have anybody git push their branches:
$ git push
At present become to the Github Repo page. You should see the branch you lot pushed up in a yellow bar at the top of the page with a button to "Compare & pull request".
Notation: Alternatively, y'all can select the branch in the drop-downward "Branch:" menu and select the branch y'all just pushed up. You'll then have a "Pull request" and "Compare" push button on the right hand side.
Click "Compare & pull asking". This will take you to the "Open a pull request" page. From here, you lot should write a brief description of what you actually changed. And you should click the "Reviewers" tab and select whoever your team decided would be the "Merge Principal". When yous're washed, click "Create pull request".
Stride 3c: Merging Pull Requests
Note that if you're a collaborator, you can merge your own pull requests. But, once more, if you're working on a team, it makes more than sense to accept one person practise all the merging and everyone else submit "Pull Requests" and assign the "Main Merger" as a reviewer just to make sure you're dealing with any merge conflicts 1 branch at a time.
So, bold yous are the one charged with taking care of all merges and someone has assigned you lot as "Reviewer" on a pull asking, when yous login to your Github you'll notice you have a notification letting you know that someone has assigned you as a reviewer. Yous'll also noticed a yellow bar indicating one of your teammates equally "requested your review on this pull asking."
Go ahead and click the "Add your review" push button.
This will take yous to the Pull Asking page. How you move forward from here is upward to you and your team. If you're working together I would apply every morning to sit downward as a team and go through pull requests together. If you lot do that, yous won't take to necessarily leave long-winded, detailed Review Summaries.
However, if you're working remotely, this volition be your main tool for letting the requester know if they need to brand changes or if y'all're going to merge their asking.
When you click "Submit review" on the "Review changes" driblet-drown your review will at present exist as a comment on the pull request thread.
When you're satisfied with the pull request, go to the bottom of the pull asking and click "Merge pull request".
Yous'll and then meet a "Pull request successfully merged and closed" message and a button to "Delete branch" which you should click.
Step iv: Rinse, Repeat
And that'due south pretty much it! Keep calculation new branches for new features and so coming together as a team to merge them into chief. Keep main make clean and deployable and don't effort to merge more than than 1 branch at a fourth dimension and you should be adept to become.
**************
Here'south the repo I used for this demonstration. I'll add the text of this article into the ReadMe. Experience free to make a pull request if there's anything you want to change or if you lot just desire to test out your pull request skills!
https://github.com/MinesJA/github_guide
Source: https://medium.com/@jonathanmines/the-ultimate-github-collaboration-guide-df816e98fb67
0 Response to "How to Upload to Github to Collaborate"
Post a Comment