【Github】Github命令行快速使用教程及常见问题解决
2017-05-03 08:10
537 查看
Git环境配置
第一步
第二步
第三步
第四步
clone至本地以及push到Github
clone
push
代码冲突常见解决方法
英文版pull和push教程
Step 1
Step 2 Unnecessary
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
如果出现“Agent admitted failure to sign using the key.Permission denied (publickey).”这个错误的话,在命令行下执行”ssh-add”,这样就可以了。
第一步
第二步
第三步
第四步
clone至本地以及push到Github
clone
push
代码冲突常见解决方法
英文版pull和push教程
Step 1
Step 2 Unnecessary
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Git环境配置
第一步:
生成ssh key,使用命令 “ssh-keygen -t rsa -C “your_email@youremail.com””,your_email是你的email默认在用户的家目录下.ssh/id_rsa.pub文件里面第二步:
回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key。第三步:
测试ssh key是否成功,使用命令“ssh -T git@github.com”,如果出现You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。如果出现“Agent admitted failure to sign using the key.Permission denied (publickey).”这个错误的话,在命令行下执行”ssh-add”,这样就可以了。
第四步:
配置Git的配置文件,username和emailgit config --global user.name "your name" //配置用户名 git config --global user.email "your email" //配置email
clone至本地以及push到Github
clone
git clone https://github.com/chenguolin/scrapy.git[/code]git pull origin masterpush
git add xxxgit commit -mgit push origin master代码冲突常见解决方法
如果系统中有一些配置文件在服务器上做了配置修改,然后后续开发又新添加一些配置项的时候,
在发布这个配置文件的时候,会发生代码冲突:
error: Your local changes to the following files would be overwritten by merge:
protected/config/main.php
Please, commit your changes or stash them before you can merge.
如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:
git stash
git pull
git stash pop
然后可以使用Git diff -w +文件名 来确认代码自动合并的情况.
反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:
git reset –hard
git pull
其中git reset是针对版本,如果想针对文件回退本地修改,使用git checkout HEAD file/to/restore英文版pull和push教程
In below section, I am writing step by step how I pushed the code in Github repo successfully
Follow the given below steps from where(Desktop/Server) you want to push the code into Github repo :Step 1:
Clone the github repo into your system. (You should first create a repo in Github)
Get repo url at right hand sidebar of your repo page. Replace your github repo’s HTTPS url with https://github.com/USER-NAME/REPO-NAME.gitgit clone https://github.com/USER-NAME/REPO-NAME.git[/code]
For EXAMPLE:git clone https://github.com/sharadchhetri/testrepo.git[/code]
After cloning will be finished, you will find the directory name matching with the name of Github repo name you just cloned.Step 2 : (Unnecessary)
Copy your code or files to REPO-NAME directory
For example, I have saved my codes in my desktop at /home/sharad/MyCode directory. Here, I am copying all codes and child directories into REPO-NAME directory .cp -rvf /home/sharad/MyCode/* /home/sharad/testrepoStep 3 :
Change to git cloned directory i.e REPO-NAME.cd REPO-NAMEStep 4 :
Set Github account username and email id for authenticationgit config --global user.email "your-email-id@example.com" git config --global user.name "Your-Github-UserName"Step 5:
Set Github URL. (This section is actually solution of this problem)git remote set-url origin https://Your-Github-UserNAme@github.com/Your-Github-UserNAme/REPO-NAME[/code]
For EXAMPLE.git remote set-url origin https://sharadchhetri@github.com/sharadchhetri/testrepo.git[/code]Step 6:
Now add all files and directory by using below given command inside REPO-NAME directory
(There is a dot in command, can you see that!)git add .Step 7:
Now write comment on commitgit commit -m 'my first commit'Step 8:
Now push the code in Github repo.
Be ready with your github account password because it will ask.git push -u origin master
I hope the solution also work for you.
4000
相关文章推荐
- Genymotion配置和使用教程以及常见问题解决方法
- 转:github使用教程(重装系统后遇到问题该文章帮我解决了)
- GitHub使用教程及常见错误解决
- Maven快速使用教程(四) Maven生命周期及常见问题
- GitHub使用教程及常见错误解决
- github使用教程与问题解决
- APPFUSE2使用说明及常见问题解决方法
- windows 2008初体验常见问题: 无线网络"没有正确配置为使用IP协议" 错误解决办法
- 使用Apache Axis部署 Web服务时的常见问题及其解决方法(IBM 官方文档)
- windows 2008初体验常见问题: 无线网络"没有正确配置为使用IP协议" 错误解决办法
- Hadoop使用常见问题以及解决方法
- Purus系统常见使用问题及解决方式FAQ 1
- 网络管理员常见九大问题快速解决方法
- Subversion版本控制使用中的常见问题及解决方法
- 使用Apache Axis部署 Web服务时的常见问题及其解决方法
- 使用Word常见问题的解决
- 使用Axis部署Web服务时的常见问题及其解决方法(转)
- DOXYGEN注释宏使用步骤及常见问题解决方法
- Linux 中软件 RAID 使用常见问题解决