一. 图形化git

1.首先下载msysgit,和 tortoisegit, 先装msysgit再装小乌龟
2.运行git按照github上说明生成秘钥对
    ssh-keygen -t rsa -C "jinhong@axinfu.com",然后会在指定的目录下生成一个.ssh文件夹
3. 运行小乌龟下的puttygen,用load的方式去改变一下id_rsa的格式为ppk文件 (这个是私钥)
4. 在小乌龟下的Pageant中点Add Key,来添加私钥
5. 复制.ssh文件夹下的id_rsa.pub文件内容到github网站中setting下的SSH keys
6. 创建git工作目录,新建文件夹右击-git克隆,参考 https://www.cnblogs.com/wangchuanyang/p/6273025.html 第7步

 
 
 
 二. windows下用git命令行
 
1. 进入创建的工作目录,选择要提交的文档或目录,右键弹出界面中点击Git Bash here
2. git pull  #每次提交项目都要先拉取,避免修改冲突
3. git status  #查看状态
4. git add .   #提交项目到当前工作目录,注意后面的点号
5. git commit -m "提交说明"
6. git push orgin master  #推送项目到相应分支,这里是master分支
 
其他命令
7. git branch -a    #可查看全部分支         git remote -v    #查看git当前工作路径
8. 回退
 可以使用 git reset --hard HEAD^ 来回退到上一次commit的状态。此命令可以用来回退到任意版本:git reset --hard  commitid 
 
 
 
三.  在ubuntu下在指定文件夹上传代码到github
 
github网页上新建仓库hong_spider
 
1. 安装git    apt-get install git
2. 生成密钥并复制公有key
生成密钥 ssh-keygen -t rsa -C "youremail@mail.com"  ,这里的邮箱地址使用用户名也可以
之后会要求确认路径和输入密码,我们使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,打开id_rsa.pub,复制里面的key
3. 回到github,进入Account Setting,左边选择SSH Keys,Add SSH,title随便填,粘贴key.
4. 验证是否成功,输入ssh -T git@github.com(普通用户下需要加上sudo),如果看到如下信息,表示成功连上github
5. 在将本地仓库上传到github之前,需要设置username和email,因为github每次commit都会记录他们。
    git config --global user.name "jack"
    git config --global user.email jack@qq.com
#6. cd要上传的本地代码仓库路径,比如我是 cd /root/mygithub,然后添加远程地址,  比如git remote add origin https://github.com/pshyms/hong_spider.git  (这一步比较迷惑,不知道和第7部是否一样)
7. 把github上的仓库拉到本地,方法是在mygithub目录下执行:git clone https://github.com/pshyms/hong_spider.git,成功的话后会生成新目录hong_spider
8. 在目录hong_spider中写入要上传的代码文件或者文件夹,执行如下代码即可  
git add .     #将任何新的或修改的文件添加到索引
git commit -m '注释信息 '   #提交

git push origin master
 
四. 有时候不知道怎么会在github上建立一个灰色的文件夹,假设为test文件夹,而且不能点进去,删除方法如下
git rm -r --cached test
git commit -m "Remove the ignored directory test"
git push -u origin master

五.  如果想把代码提交到和之前不同的仓库中

例如有远端仓库pshyms/django,它的克隆地址https://github.com/xxx/django.git。需求是把本地dailyfresh文件夹上传到xxx/django远端仓库中

1. 在本地仓库位置比如/root/mygithub中执行git clone https://github.com/xxx/django.git

2. 把dailyfresh文件夹放到克隆下来的django文件夹下

3. 在django文件夹下执行git add .  git commit -m ' .."    git push origin master

 
 
 六. 修改文件夹名字
git mv -f oldfolder newfolder
git add -u newfolder (-u选项会更新已经追踪的文件和文件夹)
git commit -m "changed the foldername whaddup"
git push origin master 七. 删除文件夹
git rm -r folder
git commit -m "delete"
git push origin master 八. 新建/删除分支
git branch new_branch #新建一个分支
git checkout new_branch #切换到新的分支名
git branch #查看一下分支情况
git push -u origin new_branch #将新分支同步到github线上
然后就是git add . git push 老路子了 如果想删除new_branch分支,首先切换到不是要删除的分支,比如git checkout master, 然后git branch -d new_branch 即可 九. pycharm上传项目到github 链接:https://blog.csdn.net/m0_37306360/article/details/79322947需要先配置好git的相关参数,比如ssh密钥和全局环境变量
    git config --global user.name "jack"
    git config --global user.email jack@qq.com

使用git提交代码简单说明的更多相关文章

  1. Git使用、Git配置、Git提交代码、Git上传

    非教程,只是自己的一个简单笔记.建议没有入门的朋友,直接看git的官方help文档: https://help.github.com/articles/set-up-git 1.注册一个git账号,超 ...

  2. Git提交代码到主分区

    git 提交代码,本地新建一个my分支,不从本地master分支直接上传,而是先从本地my分支上提交至本地master分支,然后本地master提交至远程master分支 上.前提是远程只有一个mas ...

  3. git提交代码到github

    前言:转载请注明出处:http://blog.csdn.net/hejjunlin/article/details/52117504 git提交代码到github 命令汇总: git init git ...

  4. 使用git提交代码到github,每次都要输入用户名和密码的解决方法

    自从使用git提交代码到github后,发现自己使用git的功力增长了不少,但也遇到不少问题.比如,使用git提交代码到github的时候,经常要求输入用户名和密码,类似这种: 网上有这么一种解决方法 ...

  5. Git提交代码失败: empty ident name (for <>) not allowed

    使用git提交代码,报错如下: 下午2:56 Commit failed with error 0 files committed, 1 file failed to commit: 升级 empty ...

  6. 在使用Git提交代码的时候犯了个低级错误

    今天在使用git提交代码的时候,犯了个很低级的错误,按照一切流程当我add并commit提交代码,最后使用push到远程仓库, 接下来奇怪的事情发生了,push之后,查看远程仓库代码并没有发现提交记录 ...

  7. Git提交代码报错Git push error:src refspec XXX matches more than one解决方案

    Git提交代码push时,报错这个 error: src refspec master matches more than one. error: failed to push some refs t ...

  8. git提交代码到码云

    日常代码一般提交到github比较多,但我还是钟爱马爸爸,没错就是码云. 码云是中文版的代码托管的网站,不存在打开网速问题,使用也蛮方便的,日常自己保存托管代码已经足够,平时使用git提交代码到码云是 ...

  9. git提交代码报错 trailing whitespace的解决方法

    1. git提交代码报错 trailing whitespace 禁止执行pre-commit脚本 进入到项目目录中 chmod a-x .git/hooks/pre-commit 2.git提交代码 ...

随机推荐

  1. android用户登录验证

    转自https://www.cnblogs.com/android-blogs/p/5912585.html

  2. XHTML的规范化

    -------------------siwuxie095                                 XHTML 简介         1.什么是 XHTML?     XHTM ...

  3. 无需写try/catch,也能正常处理异常

    对于企业应用的开发者来说,异常处理是一件既简单又复杂的事情.说其简单,是因为相关的编程无外乎try/catch/finally+throw而已:说其复杂,是因为我们往往很难按照我们真正需要的策略来处理 ...

  4. HTTP/2协议

    一.简介 http://toutiao.com/a6258917202906104066/

  5. [SoapUI] SOAP UI-Groovy Useful Commands

    Hi All, I have posted the SOAPUI and Groovy useful commands that may help you in your testing. Below ...

  6. SourceTree 3.0.8 跳过登陆注册

    3.0.8普通用户版account.json跳过登陆注册方法已失效,请安装企业版 https://www.sourcetreeapp.com/enterprise 企业版默认安装在 %programf ...

  7. 通过MySql自动同步刷新redis

    在服务端开发过程中,一般会使用MySQL等关系型数据库作为最终的存储引擎,Redis其实也可以作为一种键值对型的数据库,但在一些实际场景中,特别是关系型结构并不适合使用Redis直接作为数据库.这俩家 ...

  8. Android编程设置LayoutParams

    RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams)viewHolder.headerWraper.getL ...

  9. 编写高质量代码改善C#程序的157个建议——建议76: 警惕线程的优先级

    建议76: 警惕线程的优先级 线程在C#中有5个优先级:Highest.AboveNormal.Normal.BelowNormal和Lowest.讲到线程的优先级,就会涉及线程的调度.Windows ...

  10. CodeForces 47E. Cannon(离线暴力+数学)

    E. Cannon time limit per test 3 seconds memory limit per test 256 megabytes input standard input out ...