GithubHelp home page GithubHelp logo
$ mkdir tmp //创建推送目录
$ cd tmp //进入推送目录 
$ git init //设置该目录为推送
$ touch README //生成readme
$ git add README //加入修改列表
$ git commit -m 'first commit' //递交修改声明
$ git remote add origin [email protected]:abcd/tmp.git //为远程Git更名为origin
$ git push -u origin master //推送此次修改


生成新的密钥:

Ssh-keygen –t rsa –C “[email protected]” 
 

注意: 此处的邮箱地址,你可以输入自己的邮箱地址。在回车中会提示你输入一个密码,这个密码会在你提交项目时使用,如果为空的话提交项目时则不用输入。这个设置是防止别人往你的项目里提交内容。

 

打开本地C:\Documents and Settings\Administrator\.ssh\id_rsa.pub文件。此文件里面内容为刚才生成人密钥。

登陆github系统。点击右上角的 Account Settings--->SSH Public keys ---> add another public keys

把你本地生成的密钥复制到里面(key文本框中), 点击 add key 就ok了

在git中运行下面命令:

 

$ git –T [email protected]
如果提示:Hi defnngj You've successfully authenticated, but GitHub does not provide shell access. 说明你连接成功了。
假如你现在新创建了一个项目,想把它提交到github上面?

 

假设你创建好了一个项目,并切换到项目的根目录下面:

$ git status   //查看当前项目下所有文的状态,如果第一次,你会发现都红颜色的,因为它还没有交给git/github管理。

$ git add .   //(.)点表示当前目录下的所有内容,交给git管理,也就是提交到了git的本地仓库。

Ps:git的强大之处就是有一个本地仓库的概念,在没有网络的情况下可以先将更新的内容提交到本地仓库。

$ git commit –m”new natter ”  //对你更新或修改了哪些内容做一个描述。

$ git remote add origin [email protected]:defnngj/hibernate-demo.git

//如果你是第一次提交项目,这一句非常重要,这是你本地的当前的项目与远程的哪个仓库建立连接。

Ps: origin可以改为别人的名字,但是在你下一次push(提交)时,也要用你修改之后的名字。

$ git remote -v  //查看你当前项目远程连接的是哪个仓库地址。

$ git push -u origin master  //将本地的项目提交到远程仓库中。

 

 ------------------------------------------------------------

假如,你回到了家,想把公司提交的项目克隆到本地?

 

如果你是第一次想把github上面的项目克隆到本地或者要克隆别人的项目到地。

$ git clone [email protected]:defnngj/hibernate-demo.git  //在git下面切换到想存放此项目的文件目录下,运行这条命令就可以将项目克隆下来。

 

假如本地已经存在了这个项目,而仓库中又有一新的更新,如何把更的合并到本地的项目中?

$ git fetch origin    //取得远程更新,这里可以看做是准备要取了

$ git merge origin/master  //把更新的内容合并到本地分支/master

 

------------------------------------------- 

项目中删除了一些文件,如何提交?

 

假如远程仓库中已经存了aaa这个文件,我fetch了下来,并删除了aaa这个文件,想再push上到远程仓库中,并使远程仓库中的项目被新的修改覆盖(也是是远程仓库中的aaa也被删除)

$ git status   //可以看到我们删除的哪些文件

$ git add .   //删除之后的文件提交git管理。

$ git rm   src/com/hzh/hibernate/dao/aaa.java    //移除我们删除的那个文件,不然git不允许我们往远程仓库提交。

Ps: 如果你想删除的是某个目录(java包),这里想移除整个目录的内容。

$ git rm  src/com/hzh/hibernate/bbb/ -r   // -r 会把bbb/目录下的所有内容一次性移动。

 

------------------------------------------------------------------------

远程创建了一个新仓库,本地创建了一个新项目,如何使新的项目与仓库对应起来?

 

其实,这个也很简单,只是我当时对那些命令不太理解,所以比较模糊,不知如何对应。

 

$ git remote add origin [email protected]:defnngj/hibernate-demo.git

//还是这个命令,在你push项目之前加上这一句就OK了。

[email protected]:defnngj/hibernate-demo.git 就是你常见的新仓库的地址啊。git切换到新项目下,在push之前,加上这一句,我们创建的新仓库就与新项目建立了连接。

mingyun's Projects

anti-anti-spider icon anti-anti-spider

越来越多的网站具有反爬虫特性,有的用图片隐藏关键数据,有的使用反人类的验证码,建立反反爬虫的代码仓库,通过与不同特性的网站做斗争(无恶意)提高技术。(欢迎提交难以采集的网站)

audit-learning icon audit-learning

记录自己对《代码审计》的理解和总结,对危险函数的深入分析以及在p牛的博客和代码审计圈的收获

awesome-nebulas icon awesome-nebulas

星云链 DApp 开发文档、资料、工具、教程大全 | A collection of Nebulas blockchain DApp development tools and docs

awesome-php icon awesome-php

收集整理一些常用的PHP类库, 资源以及技巧. 以便在工作中迅速的查找所需...

awesome-php-zh_cn icon awesome-php-zh_cn

一个PHP资源列表,内容包括:库、框架、模板、安全、代码分析、日志、第三方库、配置工具、Web 工具、书籍、电子书、经典博文等等

awesome-python icon awesome-python

A curated list of awesome Python frameworks, libraries, software and resources

awesome-react-native icon awesome-react-native

An "awesome" type curated list of React Native components, news, tools, and learning material

blockchain_guide icon blockchain_guide

Introduce blockchain related technologies, from theory to practice with bitcoin, ethereum and hyperledger.

blog icon blog

基于yeoman、bootstrap、backbone的静态blog

blog-1 icon blog-1

:heart: PJ Blog is an open source blog built with Laravel and Vue.js. https://pigjian.com

blog-2 icon blog-2

冴羽写博客的地方,预计写四个系列:JavaScript深入系列、JavaScript专题系列、ES6系列、React系列。

christy_gift icon christy_gift

这个是我2013年送出的情人节礼物,祝各位有情人终成眷属。(地图贴图加载速度我解决不了,我当时是录在手机里的,以防万一,我只能帮到这了。)Demo:

city icon city

2015**省市地区级联效果,纯静态效果,附.sql文件,方便导入Mysql数据库

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.