git tutorial for Beginner

这篇博客介绍了Git的基本操作,包括创建仓库、添加文件、提交更改、远程仓库的使用以及SSH连接。通过实例演示了如何创建并切换分支、合并分支,以及如何设置SSH密钥来安全地连接到GitHub。此外,还涵盖了从基本理解到深入学习Git的过程。
摘要由CSDN通过智能技术生成

git tutorial for Beginner

Basic Workflow

  • create
mkdir git_test //then
git init
  • base
echo "I am a git repo." > README
//make a README file

git status
//use git status to scan which files aren’t being tracked, have been modified, deleted, etc.
PS D:\silence\Desktop\file\The road of learning\learngit\git_learn> git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Test

nothing added to commit but untracked files present (use "git add" to track)

git add README or git add .
//Stage” your changes.

git commit -m "it my second commit"
//Commit the changes

PS D:\silence\Desktop\file\The road of learning\learngit\git_learn> git add .                               PS D:\silence\Desktop\file\The road of learning\learngit\git_learn> git commit -m "it my second commit"       [master ad26fe7] it my second commit
 3 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 .README.un~
 create mode 100644 README~
 create mode 100644 Test
 
 
 //we can use git checkout to reset our file to Previous version

Remote repositories (on github)

//add remote repositories in your git config

git remote add origin https://github.com/Alan-Py/Mygitlearn.git

//push our local respositorize to remote
git push origin master

//pull the remote respositorize and merge to local 
git pull origin master

deep dive

Through the above operations, you have a basic understanding of git, then we can have a deeper learn in git. Of course it’s also a basic operation for git

//use branch 
git checkout -b develop-feature
//we can del some file in branch master
git checkout master
git add .
git commit -a -m 'third commit'
//to recover master,use merge
git merge develop-feature

we can use ssh to connect to github

//first create your key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
//then add public key to github
//modify your ssh config file like

Host github.com
	HostName github.com
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/id_edgithub

//Test it
ssh -T git@github.com

so ,we can have an initial understanding of git.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值