1. 程式人生 > >git 基本步驟

git 基本步驟

好久沒用GIT,再次撿起來,遇到了些錯誤,比如沒寫comment,導致沒提交成功,沒有先從遠端pull,導致沒push成功。

於是將這個過程記錄如下:

1:首先,跳轉到專案根目錄
2:檢視當前狀態

3:把我們要提交的檔案的資訊新增到索引庫中

4: 提交檔案到本地庫

5:合併到遠端程式碼庫(首先要將遠端庫,pull到本地,否則不能push)

5.1:沒有將遠端庫pull到本地,報錯:

6:pull遠端到本地

7:設定 git ignore 過濾檔案,.class 字尾檔案不提交到遠端

8:再次push,成功

具體如下:

1:首先,跳轉到專案根目錄
[email protected] /e/abc
$ cd CanYin-www

[email protected] /e/abc/CanYin-www (master)
$ ls
LICENSE  README.md  pom.xml  src  target
2:檢視當前狀態
$ git status;
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   src/main/java/cn/canyin/dao/MenuDao.java
        ...

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        src/main/java/cn/canyin/dao/Dao.java
        ...

no changes added to commit (use "git add" and/or "git commit -a")

3: 把我們要提交的檔案的資訊新增到索引庫中
[email protected]

/e/abc/CanYin-www (master)
$ git add .

4: 提交檔案
[email protected] /e/abc/CanYin-www (master)
$ git commit -a   #注意這一步要寫comment
[master dfce490] add menu model, changed by jonsanguo at 20140408
 27 files changed, 546 insertions(+), 11 deletions(-)
 create mode 100644 src/main/java/cn/canyin/dao/Dao.java
 ...

 5:合併到遠端程式碼庫(首先要將遠端庫,pull到本地,否則不能push)
[email protected] /e/abc/CanYin-www (master)
$ git push https://github.com/guojiangshan/canyin master
Username for 'https://github.com': guojiangshan
Password for 'https://[email protected]':
Counting objects: 81, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (45/45), done.
Writing objects: 100% (49/49), 8.40 KiB | 0 bytes/s, done.
Total 49 (delta 16), reused 0 (delta 0)
To https://github.com/guojiangshan/canyin
   66640ab..dfce490  master -> master

5.1:沒有將遠端庫pull到本地,報錯:
$ git push https://github.com/guojiangshan/canyin master
Username for 'https://github.com': guojiangshan
Password for 'https://[email protected]':
To https://github.com/guojiangshan/canyin
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/guojiangshan/canyin'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  
  
6:pull遠端到本地
$ git pull https://github.com/guojiangshan/canyin master
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From https://github.com/guojiangshan/canyin
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 .gitignore |  11 ++
 LICENSE    | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.md  |   4 +
 3 files changed, 354 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 LICENSE
 create mode 100644 README.md

7:設定 git ignore 過濾檔案,.class 字尾檔案不提交到遠端
$ echo *.class>.gitignore
檢視設定是否成功:
$ cat .gitignore
*.class

8:再次push,成功
$ git push https://github.com/guojiangshan/canyin master
Username for 'https://github.com': guojiangshan
Password for 'https://[email protected]':
Counting objects: 116, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (102/102), done.
Writing objects: 100% (115/115), 58.02 KiB | 0 bytes/s, done.
Total 115 (delta 6), reused 0 (delta 0)
To https://github.com/guojiangshan/canyin
   f7ddeea..5fd03b6  master -> master

相關推薦

git 基本步驟

好久沒用GIT,再次撿起來,遇到了些錯誤,比如沒寫comment,導致沒提交成功,沒有先從遠端pull,導致沒push成功。 於是將這個過程記錄如下: 1:首先,跳轉到專案根目錄 2:檢視當前狀態 3:把我們要提交的檔案的資訊新增到索引庫中 4: 提交檔案到本地庫 5:合併

Git同步程式碼的基本步驟

這裡給大家安利一個非常強大的程式碼同步工具:Git。它可以讓我們更輕鬆的同步其他人的程式碼,個人覺得比svn要好用很多。具體關於Git的一些細節很複雜我自己也說不太清楚,大家自行百度。下面展示一下要使用Git記錄版本庫的一些基本步驟(ps:下面的步驟都是用來同步

Git學習系列-Git基本概念

修改文件 initial config colspan 信息 stage ati 當前 目錄 本系列基於Pro Git介紹如何使用Git進行源代碼管理,以及後期如何使用Git進行項目管理。 系列初步目錄如下: 1. Git基本概念 2. Git分支操作 後續待定。 Git的

在ubuntu下安裝kaldi基本步驟

ins fort github get 識別 https http hive 沒有 註:最近在學習kaldi語音識別工具,在安裝過程中遇到了許多問題,為了解決問題,我把ubuntu和一些軟件裝了又卸,卸了又裝,解決了舊問題,又出現新問題,所以在此記錄,以備後需。 在一開始,

4-SIFT特征提取和檢測的基本步驟

str 識別 賦值 操作 高斯 特征 搜索 擬合 尺度 1- 有4個主要步驟 尺度空間的極值檢測 搜索所有尺度空間上的圖像,通過高斯微分函數來識別潛在的對尺度和選擇不變的興趣點。 特征點定位 在每個候選的位置上,通過一個擬合精細模型來確定位置尺度,關鍵點的選取依據他們的穩

netty開發程序的基本步驟(二)

ron 關閉 bound 統一管理 span 啟動 初始 ring and netty編寫程序的基本步驟如下 : Server端: 1.創建兩個線程組,一個用於接收連接bossGroup,一個用於處理連接workerGroup 2.創建一個服務器啟動類serv

git 基本用法

out dex 分支 sta ont align git init git clone 文件夾 返回上一個文件 git reset --hard HEAD~1 創建文件 mkdir 文件名 調用文件 cd 文件名 文件夾裏添加文本 touch index.html 文本添

Git基本概念

可能 個人 保存 中文 需要 cvs png 和集 方式 集中式版本控制系統:CVS+SVN 先說集中式版本控制系統,版本庫是集中存放在中央服務器的,而幹活的時候,用的都是自己的電腦,所以要先從中央服務器取得最新的版本,然後開始幹活,幹完活了,再把自己的活推送給中央服務器。

將Web項目War包部署到Tomcat服務器基本步驟

腳本文件 服務器 soft conn 解壓縮 3.1 環境 選項 def http://blog.csdn.net/inter_peng/article/details/42833587 1. 常識: 1.1 War包 War包一般是在進行Web開發時,通常是一個網站

git基本用法

臨時 標準 lob init 通過 開頭 git fetch values 管理 git基本用法 一.創建新倉庫 touch README.md 創建一個新文件 git init 初始化當前文件夾為一個Git倉庫 git add README.md 添加該文件

Git使用步驟

下一步 查看 成功 本地倉庫 git使用 color str setting pan Git是什麽? Git是目前世界上最先進的分布式版本控制系統。 SVN與Git的最主要的區別? SVN是集中式版本控制系統,版本庫是集中放在中央服務器的,而

git基本命令

git 工程 命令 images 地址 有一個 簡單 div 配置到 1.獲取工程下git地址 2.把git地址配置到環境變量來,如 把這個配置的環境變量裏面(註意:在環境便令裏面, 把git.exe去掉) 2.git簡單的基本命令 git add . 添加(註意

Git基礎入門(四)Git基本操作2

git 操作 基礎忽略文件: 在實際開發過程中總有些文件無需納入Git的管理,比如日誌文件、臨時文件等 在這種情況下,我們可以在工作目錄中創建一個名為.gitignore的文件,列出要忽略的文件名或者表達式 例:cat .gitignore *.[oa]

git —— 基本命令以及操作(No.1)

src del 刪除 blog -1 comm commit 操作 提交 git基本命令(附加描述) 1.把文件添加到暫存區$ git add readme.txt 2.把暫存區的文件文件添加到倉庫$ git commit -m "提交說明" 備註:add添加單個文

git基本語法

hub 新版 完成後 for 遠程倉庫 克隆 git ... 同時 1、基本語法 cd 目錄 mkdir xxxx-------創建文件夾 git init-------把這個目錄變成git可以管理的倉庫 git add xxxx------

筆記:git基本操作

基本概念 位置 bar 回退 let 管理 文件夾 私有 推送 原文: http://www.cnblogs.com/pingwen/p/8098035.html 1. 快速入門的基本概念 相比SVN,TFS等集中式的版本管理系統,GIT分布式管理最重要的理

Git 基本操作

gitGit 基本操作Git 的工作就是創建和保存你項目的快照及與之後的快照進行對比。本章將對有關創建與提交你的項目快照的命令作介紹。獲取與創建項目命令git init用 git init 在目錄中創建新的 Git 倉庫。 你可以在任何時候、任何目錄中這麽做,完全是本地化的。在目錄中執行 git init,就

Git 基本分支規範

新版本 master release 修改 操作 初始化 修改內容 反向 gpo 基本代碼分支應該分為兩類,一類是主要分支,包括線上主分支 Master 和開發主分支Develop;另一類是輔助分支,包括測試分支 Release,線上緊急修復分支 Hotfix,以及功能開發

基本步驟

man 目錄 url pos 函數 添加 app django 響應 1.django-admin startproject <sitename>(在Script下) 2.python manage.py startapp <name> 3.修改ap

VS下WPF自定義控件的基本步驟基本代碼實現

emp don 謝謝 generic 管理器 參數 bubuko 類的屬性 typeof 一、自定義控件的基本步驟: (本示例項目名稱為:W;添加的自定義控件名稱為) 1、 在“解決方案資源管理器”窗口的項目名上: 右擊à添加à新建項(Ctrl+Shift+A)