Coder Social home page Coder Social logo

git-tutorial's Introduction

A very gentle introduction to git and Github covering the very basics.

Basics

  • Create a local repository named after yourself separated by underscore, eg. oyvind_helgeland

  • Create a file called README.md where you write a short text snippet about yourself. I want you to use markdown for this. It is a simple formatting language used by many tools, including Github and Rstudio (this text is written in markdown!). Use the two resources below to generate the text that you paste into the file (or just write it into the README.md directly):

  • Check the status (git status). What does git tell you about the current status of the file?

  • Add the file (git add) README.md and check the status. What does git tell you about the file?

  • Commit (git commit) the file README.md and check the status. What does git tell you?

  • Check the log. What do you see?

  • Add some more info to the README.md

  • Check what's changed (git diff)

  • Add and commit README.md and check the log again. What do you see?

Github

We now want to push our file/repo to Github.

  • Log in to your Github account and create a new repository (make it public). Read the instructions carefully. We want to push an existing repository. Follow the instructions to add a remote and push.

  • What happened when we added a remote origin? (hint look at .git/config)

  • View your README.md in Github. Is the formatting as expected? Add some info to the README.md using the editing capabilities of Github.

  • Pull down the changes you just added to the remote to your local repository (git pull).

Branching

  • List the current branches of your repo (git branch)

  • Create a new branch (git branch <new branch>)

  • List branches again

  • Switch to your newly created branch (git checkout <new branch>)

  • Check the status. Confirm you are on the right branch.

  • Add a new file called branchfile1.txt with som stuff in it.

  • Add and commit the file

  • Push the repo to Github

  • Check in Github that you have two branches (master and <new branch>) and inspect the contents.

  • Switch back to the master branch

Merge conflicts

  • Pair up and select one of your repos for you both to work on.

  • Both of you pull down the repo.

  • Both of you add a file called conflict.txt with the content my name is: <your name>

  • Both push the file to the repo

  • Fix the merge conflict

git-tutorial's People

Contributors

oyhel avatar

Watchers

 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.