Git and Github tutorial

Create local repository

  1. change to working directory
  2. git init: create a new local repositary
  3. git status: see status of the working directory, files cached and files not cached
    issue: Working directory clean,
    1. No changes happen in the existing files;
    2. No new files are added to the working directory
  4. git add 'NameOfAFile': cache the changes in staging
  5. git commit -m 'CommitNote': to commit cached changes

Push to and pull from the remote repository

  1. create remote empty repository on Github website
  2. git remote add origin 'https://------.git': add the remote repository to local commputer. ‘origin’ is your name of the repository
  3. git push origin master: push local commits to branch master of origin
  4. git pull origin master: pull remote commits from branch master of origin, typically you change your file on Github website but not reflected in your local repository

Clone repository and edit locally

  1. git config --global user.name "Your name"
    git config --global user.email "Your email": define the author
  2. git clone 'https://------.git': download remote repository to local computer
  3. git remote add origin 'https://------.git'
  4. git push origin master
  5. git pull origin master

Merge repository with a dupicate one locally

  1. git remote add origin 'original repository'
    git remote add duplicate 'duplicate repository': add remote
  2. git branch graphics: create branch graphics
    git checkout graphics: switch to branch graphics
    git pull keeghan graphics: cache branch graphics of keeghan to local computer
    git checkout master: switch to master
    git merge graphics: merge branch master with branch graphics, conflicts handled beforehand.
  3. Of course you can finish merging in Github interface

Two separete ways of working on Github

  1. Contribute to a repository
    1. Fork a repository under your own account
    2. Pull from and push to remote repository, work locally
    3. Pull request to the original repository
  2. Merge a repository into yours
    1. Create your repository
    2. Pull in a repository
    3. Merge into yours
    4. Push to your remote repository

Reference

  1. The code train tutorial on Git and Github
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值