Working with Git:在 从零开始学习Git 1 中安装并初始化好Git后,接下来是学习如何使用它。
Part 1: Commit your first files
1)git init: Creating a Local Repo 这个命令是用来创建一个新的git仓库,git 的大部分命令都是在git仓库下运行的。后面不跟参数的话,就是将当前目录转换为 git 仓库。
git init [-b <branch-name> | --initial-branch=<branch-name>] [directory]
-b or --initial-branch: specifies the initial branch (default: init.defaultBranch or "master")
directory: Creates a repo in specified dir, creating it if necessary (default: current directory)
See all options at: https://git-scm.com/docs/git-init
2)git help: Getting help 查看帮助信息
git help <command>
Brings up a manual page for the given command
Example: git help init
3)git status: Show State of Working Tree 查看当前状态
Some useful options:
--short or --long: Short or long info (default: --long)
--verbose: Even longer info
-u or -uno: Include or exclude untracked files (default: -u)
See all at: https://git-scm.com/docs/git-status
4)git add: Track and Stage New Content
git add <file> [<more files> ...]
Here, the content goes from Untracked to Staged
-A: stages everything in the current directory, but BEWARE OF IT. It's often
the reason why unwanted files (binaries, caches, etc.) make it into repos.
RIGHT NOW, THE LOCAL REPO HASN'T ACTUALLY BEEN UPDATED
5)git commit: Update the Local Repo
PART 2: Working with the remote repo
step 1 : Creating a Remote Repo
去github上点击页面右上角的加号,选择"New Repository"新建一个仓库
step 2: 新建完了会看到这个。跟着做就行了。
git remote: Add and Manage Remote Repos
git remote add <name> <url>
Specifies a URL for a remote repository; and gives it an arbitrary name
"origin" is a conventional name for the remote that you update most often
This URL is for SSH auth (recommended)
我觉得我学会了!我又可以了