首页 > 其他分享 >[1094] Examples of working on an existing repository or starting a new repository

[1094] Examples of working on an existing repository or starting a new repository

时间:2025-01-16 09:04:08浏览次数:1  
标签:1094 md git repository working repo branch new

Example 01: Contribute to an existing repository

  • The repository is already on GitHub.
  • Obtain the URL of the repository.
  • Using git clone, you can download all the files within the repository to the corresponding directory.
  • Perfrom a series of operations on the repository using git.
  • Finally, push those changes back to the remote repository on GitHub.
# download a repository on GitHub to our machine
# Replace `owner/repo` with the owner and name of the repository to clone
git clone https://github.com/owner/repo.git

# change into the `repo` directory
cd repo

# create a new branch to store any new changes
git branch my-branch

# switch to that branch (line of development)
git checkout my-branch

# make changes, for example, edit `file1.md` and `file2.md` using the text editor

# stage the changed files
git add file1.md file2.md

# take a snapshot of the staging area (anything that's been added)
git commit -m "my snapshot"

# push changes to github
git push --set-upstream origin my-branch

Example 02: Start a new repository and publish it to GitHub

First, you will need to create a new repository on GitHub. For more information, see Hello WorldDo not initialize the repository with a README, .gitignore or License file. This empty repository will await your code.

# create a new directory, and initialize it with git-specific functions
git init my-repo

# change into the `my-repo` directory
cd my-repo

# create the first file in the project
touch README.md

# git isn't aware of the file, stage it
git add README.md

# take a snapshot of the staging area
git commit -m "add README to initial commit"

# provide the path for the repository you created on github
git remote add origin https://github.com/YOUR-USERNAME/YOUR-REPOSITORY-NAME.git

# push changes to github
git push --set-upstream origin main

Example 03: contribute to an existing branch on GitHub

This example assumes that you already have a project called repo on the machine and that a new branch has been pushed to GitHub since the last time changes were made locally.

# change into the `repo` directory
cd repo

# update all remote tracking branches, and the currently checked out branch
git pull

# change into the existing branch called `feature-a`
git checkout feature-a

# make changes, for example, edit `file1.md` using the text editor

# stage the changed file
git add file1.md

# take a snapshot of the staging area
git commit -m "edit file1"

# push changes to github
git push

标签:1094,md,git,repository,working,repo,branch,new
From: https://www.cnblogs.com/alex-bn-lee/p/18674099

相关文章

  • (翻译) 关于游戏网络,每个游戏程序需知 What Every Programmer Needs To Know About
    原文链接 https://gafferongames.com/post/what_every_programmer_needs_to_know_about_game_networking/ Haveyoueverwonderedhowmultiplayergameswork?Fromtheoutsideitseemsmagical:twoormoreplayerssharingaconsistentexperience(一致的体验)across......
  • git status fatal: not a git repository (or any of the parent directories): .git
    如果你已经执行了 gitclone<repository-url>,但在随后的 gitstatus 命令中仍然收到错误“fatal:notagitrepository(oranyoftheparentdirectories):.git”,那么可能是以下原因之一:当前目录不正确:克隆操作会在当前目录下创建一个新的子目录,其中包含克隆的仓库。......
  • ssm基于Java的校园二手物品交易平台的设计与实现+vue(10946)
     有需要的同学,源代码和配套文档领取,加文章最下方的名片哦一、项目演示项目演示视频二、资料介绍完整源代码(前后端源代码+SQL脚本)配套文档(LW+PPT+开题报告)远程调试控屏包运行三、技术介绍Java语言SSM框架SpringBoot框架Vue框架JSP页面Mysql数据库IDEA/Eclipse开发四、项......
  • Springboot的‌Component和Repository注解的区别
    ‌Component和Repository注解的区别主要体现在它们的应用场景和语义上。‌‌应用场景‌Component‌:这是一个通用的组件声明注解,表示该类是一个Spring管理的组件。它可以用于任何Spring管理的组件,包括业务逻辑层、数据访问层等。‌Repository‌:用于标记数据访问层的组件,即DAO(Da......
  • [Tools] Automate Creating a Local React Project, GitHub Repository, and Live Hos
    It'sfairlytrivialtocreateaReactproject,butthere'salwaysabighurdlebetweencreatingitlocallyandmakingitshareablesothatsomeoneelsecanrunit.ThislessonwalksyouthroughtheprocessofautomatingcreatingaReactproject......
  • 关于stm32f407 cherryusb初始化失败“This dwc2 version does not support dma mode,
    初学cherryusb,照着论坛帖子操作,将cherryusb软件包加入到407工程,编译完成后,下载,出现如下问题:[I/USB]dwc2has1channelsanddfifodepth(32-bitwords)is0[E/USB]Thisdwc2versiondoesnotsupportdmamode,sostopworking通过反复确认,各种定位尝试,最终发现是usb模......
  • 如何将java私有库(jar)提交至公服/公共仓库(central repository)-手动版
    如何将java私有库(jar)提交至公服/公共仓库(centralrepository)-手动版转载请著名出处https://www.cnblogs.com/funnyzpc/p/18610692准备GunPG(用于asc签名)项目代码(建议是maven结构的)sonatype账号(https://central.sonatype.com/api/auth/login)MavenHelper(Idea插......
  • tryhackme-Pre Security-What is Networking?(计算机网络基础)
    任务一:WhatisNetworking?(什么是网络)网络就是连接的事物,在计算机中,网络也是相同的概念的,只不过说,他分撒在了各种设备上面,通过这些设备连接,并且遵循一定的规则,我们可以交流。显然答案就是:网络任务二: WhatistheInternet?(什么是互联网)根据上面我了解到了什么是网络 ,也......
  • 启动容器报WARNING: IPv4 forwarding is disabled. Networking will not work.
    我运行容器dockerrun--namemy-nginx-d-p8080:80nginx:latest报这个错误WARNING:IPv4forwardingisdisabled.Networkingwillnotwork.查询发现是因为Ipv4转发功能被禁用了IP转发是指在一个路由器上允许数据包从一个接口转发到另一个接口的能力。在Docker中,......
  • P1094 [NOIP2007 普及组] 纪念品分组
    [NOIP2007普及组]纪念品分组题目背景NOIP2007普及组T2题目描述元旦快到了,校学生会让乐乐负责新年晚会的纪念品发放工作。为使得参加晚会的同学所获得的纪念品价值相对均衡,他要把购来的纪念品根据价格进行分组,但每组最多只能包括两件纪念品,并且每组纪念品的价格之和不能......