Giter Club home page Giter Club logo

git-learning's Introduction

Git 學習筆記

tags: git

Git 使用者相關

第一次使用Git時,需設定使用者名稱與信箱

$ git config --global user.name "user-name"
$ git config --global user.email "user-email"

顯示使用者名稱
$ git config user.name
顯示使用者信箱
$ git config user.email


建立 Git 專案

初始化Git,將檔案夾設定為Git專案

$ git init 

指定資料夾
$ git init {directory-name} 

複製現有專案的方式 HTTP網址複製:

$ git clone url

例:以 HTTP 方式自github複製專案

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY

例:以 SSH 方式自github複製專案

$ git clone [email protected]:YOUR-USERNAME/YOUR-REPOSITORY

:::danger !! 2021年八月後,自github上複製專案將需要輸入 access token :::


查看 git 狀態

$ git status

檢視提交紀錄
$ git log 

新增檔案至 暫存區(stage)

stage

增加檔案至暫存區
$ git add {filename}

增加全部檔案至暫存區
$ git add .

新增檔案至分支(repository)

$ git commit -m "commit-message"

若只輸入git commit則將開啟編輯器,git會要求輸入提交信息


推送

$ git push

分支

應隨時注意自已目前在哪個分支,預設主分支通常為main (原為master,因政治因素修正)

查看目前分支
$ git branch 

創建分支
$ git branch {branch-name} 

前往分支
$ git checkout {branch-name}

將分支合併
$ git merge {branch-name 要合併的分支名稱}

git pull

抓取分支

git pull

git [-C <path>] pull

conflict 衝突

git rebase

pull request

git fetch

git merge

git switch

github flow 協作模式

將既有專案與 github 上的 repo 連結

$ git remote add origin {github}/{local Directory Name.git}

$ git branch -M main

git-learning's People

Contributors

codesh85 avatar annie794922 avatar eiana12 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.