http://blog.163.com/xianfuying@126/blog/static/21960005201181482518631/
在~/.ssh的位置vi id_rsa.pub
拷贝的时候id_rsa.pub里面从
sh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQE....................................
到email地址结束。
第一次生成的key居然Access denied了。。
重新搞了一个成功。
然后
git remote add origin git@github.com:用户名/项目名称.git
git pull origin master 就PULL一个以前folk的项目下来了。
下次在自己的服务器上试试。
Guides: Tell git your user name and email address Git needs to know your username and email address to properly tag your commits. This is normally done on a global level: [~]$ git config --global user.name "lubin" [~]$ git config --global user.email lubin.z@gmail.com You can override these settings on a per-repo basis: [~/path/to/repo]$ git config user.name "lubin" [~/path/to/repo]$ git config user.email lubin.z@gmail.com This change will only affect future commits. Past commits will retain the username and address they were committed with. Some tools will assume your github config is in the same place (http://github.com/blog/180-local-github-config): [~]$ git config --global github.user lubin [~]$ git config --global github.token 6ef8395fecf207165f1a82178ae1b984
搞砸了,怎么恢复?
删光本地文件,这时候pull会说 already-up-to-date
那么checkout 上一版的hash id:
git checkout AAAAB3NzaC1yc2EAAAABIwAAAQE..
这样本地版本就低于远程的,再pull就可以恢复回去了!
有了搞砸之前的文件,可以重头来过。
但是改好后,可以commit,并不能push成功。
马上push会出现:
HEAD detached at 0d731b8
nothing to commit, working directory clean
由于脱离了head,指向的是一次commit的id
必须:
git checkout master
会提示: Switched to branch 'master' Your branch is up-to-date with 'origin/master'.
这样做之前备份好之前修改好的代码,或者,根本就只是在脱离头部的时候将上一版拷出去改的也可以。
回到head,放入最新的文件,commit,push成功。
如果一开始就没有备份,那么只好git clone 后接git remote -v查询到的git库地址即可。
有一点要注意的是,clone下来如果git项目文件夹被覆盖一次,需要终端cd .. 然后重新进入该目录,否则会:
fatal: Unable to read current working directory: No such file or directory
切勿惊慌。。。
如果只是working tree被改坏了,文件没有什么改动,可以reset --keep
git reset [--hard|soft|mixed|merge|keep] [<commit>或HEAD]
重设working tree中发生变化的文件。
index,执行git add的操作,会对文件创建索引,所有被跟踪的文件索引会放入index,表示文件被修改待提交 working tree,当前工作区,被修改但未被add的文件,存储在工作区 ORIG_HEAD,用于指向前一个操作状态,每次的commit或者pull或者reset,git 都会把老的HEAD拷贝到.git/ORIG_HEAD,通过对ORIG_HEAD的引用可 以指向前一次的操作状态 1、hard(慎用) 重设index和working tree,所有改变都会被丢弃,包括文件的修改、新增、删除等操作,并把HEAD指向<commit>, 因此通过git log查看版本提交记录,被reset的版本记录会被丢弃,但可以通过git reflog查看 2、soft 不重设index和working tree,仅仅将HEAD指向<commit>,表示已经commit的文件会取消commit, 通过git status查看,文件会处于待commit状态“Changes to be committed” 3、mixed(默认) 重设index,但不重设working tree,表示已经被add的文件,被取消add, 通过git status查看,文件会处于待添加索引状态 “Changes not staged for commit” 4、merge 重设index,重设working tree中发生变化的文件,但是保留index和working tree不一致的文件 5、keep 重设index,重设working tree中发生变化的文件