git init
git clone [url] 例:git clone https://github.com/you/yourpro.git
// 添加一个新的 remote 远程仓库 git remote add [remote-name] [url] 例:git remote add origin https://github.com/you/yourpro.git origin:至关于该远程仓库的别名 // 列出全部 remote 的别名 git remote // 列出全部 remote 的 url git remote -v // 删除一个 renote git remote rm [name] // 重命名 remote git remote rename [old-name] [new-name]
git rm file.txt // 从版本库中移除,删除文件 git rm file.txt -cached // 从版本库中移除,不删除原始文件 git rm -r xxx // 从版本库中删除指定文件夹
git add . // 添加全部文件 git add file.txt // 添加指定文件
git commit -m "注释"
// 撤销最近的一个提交. git revert HEAD // 取消 commit + add git reset --mixed // 取消 commit git reset --soft // 取消 commit + add + local working git reset --hard
git push [remote-name] [loca-branch]:[remote-branch] 例:git push origin master:master
git status
git fetch [remote-name]/[branch]
git merge [remote-name]/[branch]
pull = fetch + merge git pull [remote-name] [branch] 例:git pull origin master
// 列出分支 git branch // 建立一个新的分支 git branch (branch-name) // 删除一个分支 git branch -d (branch-nam) // 删除 remote 的分支 git push (remote-name) :(remote-branch)
// 切换到一个分支 git checkout [branch-name] // 建立并切换到该分支 git checkout -b [branch-name]
##与github创建ssh通讯,让Git操做免去输入密码的繁琐。git
ssh key must begin with 'ssh-ed25519', 'ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', or 'ecdsa-sha2-nistp521'. -- from githubgithub
根据以上文段咱们能够知道github所支持的ssh密匙类型,这里咱们建立ssh-rsa密匙。 在command line 中输入如下指令:``ssh-keygen -t rsa``去建立一个ssh-rsa密匙。若是你并不须要为你的密匙建立密码和修更名字,那么就一路回车就OK,若是你须要,请您自行Google翻译,由于只是英文问题。
$ ssh-keygen -t rsa Generating public/private rsa key pair. //您能够根据括号中的路径来判断你的.ssh文件放在了什么地方 Enter file in which to save the key (/c/Users/Liang Guan Quan/.ssh/id_rsa):缓存
ssh git@github.com
命令来连通一下github,若是你在response里面看到了你github帐号名,那么就说明配置成功了。 let's enjoy github 在本地仓库根目录建立 .gitignore 文件。Win7 下不能直接建立,能够建立 ".gitignore." 文件,后面的标点自动被忽略;服务器
/.idea // 过滤指定文件夹 /fd/* // 忽略根目录下的 /fd/ 目录的所有内容; *.iml // 过滤指定的全部文件 !.gitignore // 不忽略该文件