Giter VIP home page Giter VIP logo

git_cs125's Introduction

Git Guide MP7

(Trigger Warning: I'm only slightly less of a noob than y'all so be nice and pls tell me if something here is incorrect.)

Other Guides

There is already an intro to git / version control on the 125 website. Read this first for a refresher on the importance of version control. This guide will be about using git to collaborate on MP7. There are also much more complete guides such as the Atlassian Git Tutorial or Git's own tutorial. These tutorials cover about everything you need to know about git but may be a bit cumbersome for newcomers. This guide will be about quickly setting up a repository for you and your partner to easily collaborate on MP7.

Creating a new repo on GitHub

You wont be able to collaborate without a shared git repository. First, have one partner create a new repository on GitHub. Give it an apropriate name and description. Make sure it is public and don't add any initial files.

new_repo.png

Creating a new repo on your computer

A new repo on GitHub is useless if you and you partner can't access it on your own machines. Have one partner navigate to directory of your project. (Probably something like /path/to/AndroidStudioProjects/my_cool_mp7_project/) If you haven't yet created you project do so now.

Next open the terminal in this directory. On linux you probably have an option to right click -> open terminal here. On windows, right click -> git bash here. On mac you will have to open the terminal the usual way then cd into your projects directory. (Unless you have enabled the option)

Now you can initialize the repository with git init. If you run git status you will see a bunch of red "untracked files". These files need to be staged so you can commit them. (More on that here) You can add all files with git add . or add files individually with git add /path/to/my_file.ext. If you run git status again you will see that your files have been staged and are now colored green.

Now that your files are staged you can commit them with git commit this will pull up your default editor, which is probably vim or nano. If it's vim you might have some issues. The editor is opened so you can write a commit message. If you want to avoid the struggles of closing vim, you can also specify a commit message in the command itself git commit -m "my commit message".

Lastly you have to add the remote repository you made on GitHub and push your changes. This can be done with git remote add origin https://github.com/myusername/my_repo_name.git and git push -u origin master.

Congratulations! You have created your first git repository on GitHub!

Here are the steps more succinctly:

cd /path/to/AndroidStudioProjects/my_cool_mp7_project/
git init
git add .
git commit -m "my commit message"
git remote add origin https://github.com/myusername/my_repo_name.git
git push -u origin master

Adding your partner

In order for you guys to collaborate you first need to add your partner as a collaborator. This will give them commit access in your repo (only you have commit access by default). You can find collaborators in the settings tab of your repository's GitHub page.

find_collaborators.png

Seach for your partner's GitHub username. Make sure you chose the correct one.

collaborate.png

When you add them as a collaborator they will be sent an email. Once they accept, they will have to clone your repo.

From the point of view of the partner who did not create the repo the command is:

git clone https://github.com/mypartnersusername/their_repo_name.git

General Git Workflow

(For both partners)

Every time you make a significant change you can stage the changes with git add my_changed_file.ext (to add my_changed_file.ext) or git add . to add all files. Changes are committed with git commit (to write the commit message in the editor) or git commit -m "my commit message" (you probably want to use this one). Push to GitHub with git push origin master (Always after you commit though).

Again, after you make changes:

git add .
git commit -m "my commit message"
git push origin master

To retrieve changes that your partner has made:

git pull --no-edit

Review

Remember, the default terminal on mac and linux should work for git but on windows you will have to run all commands from the git bash terminal, not the command prompt.

To be done once after creating your repository:

cd /path/to/AndroidStudioProjects/my_cool_mp7_project/
git init
git add .
git commit -m "my commit message"
git remote add origin https://github.com/myusername/my_repo_name.git
git push -u origin master

To be done once by the partner who did not create the repository:

git clone https://github.com/mypartnersusername/their_repo_name.git

To be done every time you want to commit and push changes:

git add .
git commit -m "my commit message"
git push origin master

To be done every time you want to pull your partners changes:

git pull --no-edit

Thanks for reading my guide! Good luck on MP7!

git_cs125's People

Contributors

adrianisuru avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.