1. 程式人生 > >Git託管:將本地專案程式碼上傳(push)到自己的Git repository

Git託管:將本地專案程式碼上傳(push)到自己的Git repository

  1. 首先下載並安裝git版本控制軟體,我安裝的是Git-1.9.2-preview20140411,這裡是我上傳的有需要的可以download然後安裝即可。http://download.csdn.net/detail/u013295579/9793810【下載連結】
    以下命令可以檢視自己安裝的版本:
$ git --version
git version 1.9.2.msysgit.0

2.步入主題–>>在你需要上傳的檔案絕對目錄下右鍵,在選單列表裡面開啟git bash,在終端裡輸入:

$ git init
Reinitialized existing Git repository in
e:/GITHUBSource/WorkStation/.git/

先來看下終端的git command都有哪些:

$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>] The most commonly used git commands are: add Add file contents to the index bisect Find by binary search the change that introduced a bug branch List, create, or delete branches checkout Checkout a branch or paths to the working tree clone Clone a
repository into a new directory commit Record changes to the repository diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository grep Print lines matching a pattern init Create an empty Git repository or reinitialize an existing one log Show commit logs merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects rebase Forward-port local commits to the updated upstream head reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index show Show various types of objects status Show the working tree status tag Create, list, delete or verify a tag object signed with GPG 'git help -a' and 'git help -g' lists available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept.

看到:init –Create an empty Git repository or reinitialize an existing one.因此我們可以通過它來建立一個空的git託管倉庫或者重新初始化已經存在的倉庫。

3.use “git add …” to include in what will be committed 即:使用git add命令將檔案加入暫存區

$ git add Project #(Project :the file what you want to add.)
warning: LF will be replaced by CRLF in Project/Order_Client/AndroidManifest.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Project/Order_Client/bin/AndroidManifest.xml.
The file will have its original line endings in your working directory.

可以通過:$ git config core.qutocrlf false 來處理add(將檔案加入暫存區)時的警告訊息

4.使用git commit命令將當前暫存區中的檔案實際儲存到倉庫歷史記錄中。通過這些記錄,可以在工作樹中復原檔案。個人覺得這和資料庫的日值檔案的作用相同,先將操作寫入日誌,再對資料庫操作。

$ git commit -m "this is a Learning Project"
[master (root-commit) 1cadc7e] this is a Learning Project
warning: LF will be replaced by CRLF in Project/Order_Client/AndroidManifest.xml.

git commit -m “First commit” -m引數後的”this is a Learning Project”稱作為提交資訊,是對這個提交的概述。

5.網頁登陸你的github賬號,建立倉庫這裡寫圖片描述
這裡寫圖片描述
6.copy你的倉庫路徑
你新建的倉庫地址
7.新增遠端倉庫,在GitHub上建立的倉庫路徑位”[email protected]:使用者名稱/git-tutorial.git”. git remote add 命令可將它設定成本地倉庫的遠端倉庫。

$  git remote add origin https://github.com/******/Project

7.git pull–獲取最新的遠端倉庫分支。

$ git pull origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/Jacoobr/Project
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

8.建立同名分支,當工作告一段落時,定期將這個特性分支push到遠端倉庫。

$ git push -u origin master
Username for 'https://github.com': ***
Password for 'https://***@github.com':
Counting objects: 238, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (218/218), done.
Writing objects: 100% (237/237), 1.12 MiB | 119.00 KiB/s, done.
Total 237 (delta 52), reused 0 (delta 0)
remote: Resolving deltas: 100% (52/52), done.
To https://github.com/***/Project
   88b0e11..0935b3d  master -> master
Branch master set up to track remote branch master from origin.

建立分支過程要輸入使用者名稱和使用者密碼
之後可以登陸git檢視下自己提交的程式碼庫
這裡寫圖片描述
bingo!Look,We make it!

相關推薦

Git託管本地專案程式碼(push)到自己Git repository

首先下載並安裝git版本控制軟體,我安裝的是Git-1.9.2-preview20140411,這裡是我上傳的有需要的可以download然後安裝即可。http://download.csdn.net/detail/u013295579/9793810【下載連

Mac Git 學習教程 之 本地專案程式碼到GitHub

在終端上輸入命令,拉一下遠端的程式碼,如出現報錯“fatal: refusing to merge unrelated histories”,只需要在該命令列新增允許即可“--allow-unrelated-histories”,然後跳出文件說明,退出即可,具體如下圖

詳細教程本地項目到github

--help ror list led publickey id_rsa -h 一行 ble   作為 一個工程師,將本地項目上傳到github進行備份和分享是一個不錯的技能,一來可以方便以後的工作,二來可以分享自己的成果。所以下面本人詳細教大家如何將本地項目上傳到gith

Git的使用--本地項目到Github

所有 倉庫 文件夾 code title img pull gen info 1.新建一個項目(文件夾),將要上傳的項目放進去; test上傳github是我新建的文件夾,es6-Setting-up-the-environment是我要上傳的項目; 2.進入D:\tes

如何本地專案檔案至github

我選擇了Linux環境,在Linux系統指定的專案檔案上傳到github上。 一、準備工作          首先準備,一臺裝有Ubuntu Linux的電腦。我們所有的操作是在這臺電腦上進行的。接下來開始開啟終端(Crt+alt+T)。這裡我是在Windows系統上使用P

利用github和git命令,本地專案共享到伺服器

一、步驟   1. 建立專案根目錄 mkdir 資料夾名   2. 初始化資料夾 git init   3. 配置使用者名稱和郵箱(第一次配置後,不需要再登入) git config user.name 名字 git config user.email 郵箱

使用git專案程式碼到github流程

用git將專案程式碼上傳到github流程   先上常用語句 git add . git commit -m "img commit" $ git pull $ git push -u or

如何用git專案程式碼到github

配置Git 我們先在電腦硬盤裡找一塊地方存放本地倉庫,比如我們把本地倉庫建立在C:\MyRepository\1ke_test資料夾下 進入1ke_test資料夾 滑鼠右鍵操作如下步驟: 1)在本地倉庫裡右鍵選擇Git Init Here,會多出來一個.git資料夾,這就表示本地git建立成功。右

本地項目git

mit long detail bsp span strong ilo details 命令 第一步:建立git倉庫 cd到你的本地項目根目錄下,執行git命令 git init 第二步:將項目的所有文件添加到倉庫中 git add .   註意:如果想添加某個特

Git的使用--如何本地項目到Github

git教程 .com example readme key 創建 round 一個 提示 很早之前就註冊了Github,但對其使用一直懵懵懂懂,很不熟練。直到昨天做完百度前端技術學院的task,想把代碼托管到Github上的時候發現自己對於Git的操作是如此之愚鈍,所以今天

如何用命令本地項目git

http tps repos post 一個 ast 操作 img 問號 1. 打開在你的項目文件夾,輸入下面的命令 git init 輸完上面的命令,文件夾中會出現一個.git文件夾,如下圖所示,其他的的文件也會出現藍色小問號的標誌 2. 添加所有文件

如何本地項目Git 版本庫

命令 所有 git 告訴 使用 clas body 管理 忘記 1、(先進入項目文件夾)通過命令 git init 把這個目錄變成git可以管理的倉庫 git init 2、把文件添加到版本庫中,使用命令 git add .添加到暫存區裏面去,不要忘記後面的小數點

如何通過git本地程式碼到伺服器

注意:安裝的前提條件是配置好Git的相關環境或者安裝好git.exe,此處不再重點提及 上傳的步驟:(本文采用git 命令介面進行操作) ( git config --global user.email "[email protected]" git config --global use

如何用命令本地項目git和ssh配置

pub 上傳 posit comm pos pull 地址 rem 關聯 嘛,就是將服務器上的網站和本地同步。首先是上傳服務器上的網站到github倉庫git initgit add .git commit -m ‘‘關聯遠程倉庫,先去github上新建一個,new rep

伺服器運維SFTP本地資料夾至centos伺服器中

一:上傳檔案 SFTP方式上傳檔案比較簡單,我這裡使用的是 Xshell6 ,通過下圖方式進行SFTP連線後,即可通過命令進行本地與伺服器間檔案的上傳。 常用命令: 1、 ls和lls            ls是

Git本地的倉庫至碼雲

需要條件: 1)碼雲上面有和本地名字相同的倉庫 2)碼雲上面的倉庫的資料夾內為空 1.建立一個倉庫 $ mkdir learngit $ cd learngit 2.初始化一個Git倉庫,使用git init命令。會生成一個.git檔案,加入版本控制 $ git init

用gitbash專案程式碼到GitHub

配置Git 我們先在電腦硬盤裡找一塊地方存放本地倉庫,比如我們把本地倉庫建立在C:\MyRepository\1ke_test資料夾下 進入1ke_test資料夾 滑鼠右鍵操作如下步驟: 1)在本地倉庫裡右鍵選擇Git Init Here,會多出來一個.git資料夾,這就表示本地git建立成功。右

如何webstrom本地程式碼到github

在git push時一直報錯403(被拒絕),but why?又沒有解釋,後面在網上找了許多解決方案,自己終於解決了。我將詳細流程記錄下。1、首先確保你有一個github賬戶,本地的git也安裝好。2、windows系統,在任意資料夾下“單擊滑鼠右鍵”可開啟如下,選擇git

如何用命令本地項目到github

軟件 是把 tar 地址 key 安裝方法 打開 com baidu 一、Git終端軟件安裝 1、下載windows上git終端,類似shell工具,下載地址:http://msysgit.github.io/ 2、安裝方法,打開文件,一路點擊Next即可 3、安裝完成,

本地代碼到github

版本 目的 mage font AD 參數 master bsp 拉取 本質上就是本地倉庫與遠程倉庫這兩個倉庫進行遠程同步的過程 一.創建本地倉庫 1.cd到你的本地項目根目錄下,執行git命令,git init 2.將項目的所有文件添加到倉庫中,git add -A