1.使用git bash创建一个文件夹

 cd g:
 cd GitLearning
 mkdir LearningPythonDiary

2.初始化代码仓库

 git init

3.添加一个文件到仓库的缓存区(从工作目录添加到缓存区)

 git add filename

4.将添加的文件从缓存区提交到HEAD(最近一次提交后的结果)

 git commit -m "代码提交信息"

5.将本地代码仓库中代码push到gitHub上

  • 首先需要用我们在gitHub上的邮箱与用户名生成一个.ssh(id_rsa.pub)
     git config --global user.name "Your Name Here"  
     # Sets the default name for git to use when you commit
    
     git config --global user.email "your_email@example.com"   
     # Sets the default email for git to use when you commit
    

然后将生成的id_rsa.pub 中最后== 添加上自己在gitHub上的邮箱地址,全选一起拷贝到在gitHub上同样项目的 domay key中。

  • 然后在git中创建主干线(ssh方式)

     git remote add origin git@github.com:username/LearningPythonDiary.git
    

    也可以这样创建(https方式):

     git remote add origin https://github.com/username/LearningPythonDiary.git
    

    不过这样创建就是每次提交的时候都要输入用户名与密码,比较繁琐。

  • push到github中的同名项目中

     git push origin master
    

6.将gitHub上的代码更新到本地

 git pull origin master

7.从gitHub上复制项目到本地localhost

 git clone https://github.com/username/LearningPythonDiary.git master

转自https://github.com/peterluo/LearningPythonDiary

Like this post? Share on:


doobom Avatar doobom is write a bug.
Comments

So what do you think? Did I miss something? Is any part unclear? Leave your comments below.

comments powered by Disqus

Keep Reading


Published

Category

git

Tags

Stay in Touch

Get New Release Alert