git更新github仓库

git更新github仓库

在github创建一个configRepo仓库,并push提交数据到该仓库中。

1. git init
2. git add client1/
3. git commit -m "first commit"
4. git branch -M main    # 当前master分支重命名为main
5. git remote add origin git@github.com:LiHangGithub/configRepo.git
6. git push -u origin main

在之后的开发中,对代码进行修改更新。

第一步,先把configRepo仓库中的数据clone到本地

$ git clone [email protected]:LiHangGithub/configRepo.git 
$ cd configRepo/              # 切换到configRepo仓库目录下

之后,在对仓库内的数据修改后。

$ git status  # 查看修改之后仓库的状况
On branch main

Your branch is up to date with 'origin/main'.
Changes not staged for commit:
  (use "git add/rm ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
        deleted:    client1/client1-dev.txt
        deleted:    client1/client1-prod.txt
        deleted:    client1/client1-test.txt
Untracked files:
  (use "git add ..." to include in what will be committed)
        client1/client1-dev.properties
        client1/client1-prod.properties
        client1/client1-test.properties
$ git add .
$ git commit -m "update github"
$ git pull          # 获取最新提交的分支
$ git push origin main  # 
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 341 bytes | 341.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:LiHangGithub/configRepo.git
   8d71f24..9fcb8dd  main -> main

此时github的仓库中的数据就已经更新了

你可能感兴趣的:(Github,git,github)