git
2017-11-24 本文已影响5人
iOS打怪升级
1.https方式
…or create a new repository on the command line
echo "# NestVC" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/TianQiLi/NestVC.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/TianQiLi/NestVC.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
Import code
…pull code from another repository
git pull orgin master
2.SSH 方式
…or create a new repository on the command line
echo "# NestVC" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:TianQiLi/NestVC.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin git@github.com:TianQiLi/NestVC.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
Import code
3.使用细节
3.1 Git中全局忽略.DS_Store文件 ____or删除.DS_Store
当前目录添加文件.gitignore 文件,文件内容为需要忽略的文件。可以使用如下命令添加:
echo ".DS_Store" >> .gitignore
echo ".gitignore" >> .gitignore
4.git 命令解释:
- add : 添加文件;
git-add - Add file contents to the index
例:git add [目录/文件路径]
git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
[--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]
[--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]
[--] [<pathspec>...]
- rm : 删除文件;
git-rm - Remove files from the working tree and from the index
例:git rm [目录/文件]
git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>...
-r 递归
-f
--ignore-unmatch 忽略不匹配的
- commit : 提交文件文件;
git-commit - Record changes to the repository
例:git commit -a -m "msg"
git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
[--dry-run] [(-c | -C | --fixup | --squash) <commit>]
[-F <file> | -m <msg>] [--reset-author] [--allow-empty]
[--allow-empty-message] [--no-verify] [-e] [--author=<author>]
[--date=<date>] [--cleanup=<mode>] [--[no-]status]
[-i | -o] [-S[<keyid>]] [--] [<file>...]-r 递归
-a 包括所有删除(d) 变更的(m) ,不包含未添加的; 否则变更的提交前需要重新add 一下
-m 添加日志说明
4.remote : 配置远程
git-commit - Record changes to the repository
配置远程仓库链接
例:git remote add orgin "http://xxxxxxxxx"
修改本地仓库名称
git remote rename oldName newName
移动本地仓库
git remote remove name
git remote [-v | --verbose]
or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
or: git remote rename <old> <new>
or: git remote remove <name>
or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
or: git remote [-v | --verbose] show [-n] <name>
or: git remote prune [-n | --dry-run] <name>
or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
or: git remote set-branches [--add] <name> <branch>...
or: git remote get-url [--push] [--all] <name>
or: git remote set-url [--push] <name> <newurl> [<oldurl>]
or: git remote set-url --add <name> <newurl>
or: git remote set-url --delete <name> <url>
3.pull : 更新到本地;
git-pull - Fetch from and integrate with another repository or a local branch
例:git pull orgin master
git pull [options] [<repository> [<refspec>...]]