github

本文详细介绍Git的基本使用流程,包括初始化本地存储库、添加文件、查看状态、提交更改、创建及切换分支等操作,并演示如何与远程仓库进行同步,适合Git初学者快速上手。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[b]添加本地存储:[/b]

git init : init repository /.git/

git status :查看存储状态

# On branch master
#
# Initial commit
#
nothing to­ commit (c­reate/copy­ files and­ use "git ­add" to tr­ack)
Success
!


git add Hello.java : put file into staging area

git add '*.txt' : add

git reset­ octof­amily/octo­dog.txt: put file staged into unstage

git commi­t -m 'Add cute octoc­at story­' :
store staged file in the local respository
with describing message


为~/.gitconfig 文件添加 用户默认用户名和邮件的配置文件
git config --global user.email “abc@ab.com”

git config --global user.name "abc"


[master (r­oot-commit­) d0fe168]­ Add cute ­octocat st­ory
1 file changed, 1 insertion(+)
create mode 100644 octocat.txt
Success!


git log :查看每次commit 的信息


[b]添加remote repository[/b]

git remot­e add origi­n git@g­ithub.com:­hlxinyan/t­ry_git.git­
git push -u origi­n maste­r:
origin:remote repo name
master:the default local branch name
-u :tells Git to remember the parameters,
so that next time we can simply run git push
git push corp HEAD:refs/for/master

git pull origi­n maste­r:check for changes on our GitHub repository
and pull down any new changes
git diff HEAD:
HEAD:是一个指针,记录着 用户本人做的不同提交的位置
git diff --sta­ged:比较处于staged 文件
diff --git a/octocat.txt b/octocat.txt
index 7d8d808..e725ef6 100644
--- a/octocat.txt
+++ b/octocat.txt
@@ -1 +1 @@
-A Tale of Two Octocats
+A Tale of Two Octocats and an Octodog
Success!

[/size]

git checkout -- octoc­at.txt :从remote中获取otcocat 文件覆盖本地


[b]创建branch[/b]
git checkout -b new_branch or

git branch new_branch
git checkout new_branch

[b]切换分支[/b]
git checkout master

[b]分支合并[/b]
git merge­ clean­_up

[b]删除分支 [/b]
git branch -d <branch name>

[b]删除文件或者文件夹[/b]
git rm '*.tx­t'
git rm -r folder_of_cats

[b]提交branch 变化[/b]
git commit -m 'Commit delete all txt files'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值