【Git】从零开始学习Git 2:如何使用Git

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)

我觉得我学会了!我又可以了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值