Coder Social home page Coder Social logo

github_workshop's Introduction

Github Workshop

by Amirhossein, [email protected]

Contents

Before the workshop

  • Make sure you have git installed on your system. Need a link?

    https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

  • Sign up for a github account here: www.github.com

  • Setup your account on your system:

    Using the username an e-mail address you used to sign-up on github, config the git installed on your system using the following commands (change “username“ and “e-mail“ to yours):

> git config --global user.name “username”
> git config --global user.email “e-mail”

You can double check the config using the following command:

git config --list

or learn more about configuring your repository using:

git config --help
  • We will be mostly using terminal/command-line to work with git and github. If you are not familiar with commands and working with terminal, you can take a look at this introduction for beginners. If you are using windows, here it is a list of commands.

Basics

Open you terminal or command-line (cmd).

Go to a specific folder/directory

> cd /home/my_project/ 		# change the directory. (linux and windows (and mac?))

Create a new repository (local and online):

You have 2 options to create a new repository. You can start the remote repository and clone (download) it. Or you can create your local repository and then upload it to your github account. The first option is much easier and involves fewer steps.

  • Option 1: Got to the github website an create a repository under your account. Then:
> git clone "Repository URL" 			#initialize a repo

or

  • Option 2:
> git init 			#initialize a repo

Then you need to create a repository on github with the same name, and then:

$ git remote add origin remote "repository-URL"		# Sets the new remote
$ git remote -v						# Verifies the new remote URL

Start building up your project

> git add				#add files to the stage (from working irectory to staging area)
> git commit -m "commit-message"	#add a checkpoint to your local repo (from staging area to local repo)
> git push origin master		#push changes to the remote repo (from local repo to remote repo)
> git pull origin master		#pull changes from the remote repo (from remote repo to local repo)

you can check the satus of your reposity using:

> git status			#check the status of your repo

or compare your stage with your local repository using:

git diff --staged

Group Projects

Branching

Create a new branch an switch to it:

git checkout -b "branch-name"

Make some changes to your file, and push it to your remote repo. Then check your github repository using the website. Where are the new changes?

Merging (Pull Request)

Use the website and go to the branch you want to merge to master. Hit the button create a pull request.

If there's no conflict you can simply merge, if there's, then you need to resolve conflicts before merging.

To resolve the conflicts you have two options: (a) Using the website. Make sure you update your local repos using pull afterward. (b) Using command-line and git:

> git fetch origin	 		# fetch the whole remote
> git checkout "branch-name"		# checkot to your local branch, if you're not
> git rebase origin/master		# Add master changes to your local branch
> git push -f 				# force push your local rebased branch into your remote branch

Contribute to projects owned by others

First fork their repo to your account, clone your fork to your local machine, submit the changes, and then:

Add a remote to the main repo (upstream):

git remote add upstream "address"	#(https://github.com/afshinfard/github_workshop.git)
git remote -v

Update your local repo/branch using the upstream repo/branch:

git fetch upstream 			# Fetch all the changes in the upstream repo
git checkout "branch-name"		# checkout (switch to) the branch you want to merge
git merge upstream/"branch-name"	# Upates your branch with the upstream repo/branch

Push changes to the remote repos/branches:

git push origin "branch-name"		# push to your own remote repo
git push upstream "branch-name"		# push to upstream remote repo

Bonus

Make a README.md

github_workshop's People

Contributors

aafshinfard avatar nimaash avatar abbasnikbakht avatar

Watchers

James Cloos 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.