Git 重新命名操作

2021-09-07 07:18:15 字數 1154 閱讀 4698

截至目前,tome 和jerry 都使用手動命令來編譯自己的專案。jerry 決定為他們的專案建立 makefile,並給予適當的名稱來命名「string.c」 檔案。

[jerry@centos project]$ pwd /home/jerry/jerry_repo/project

[jerry@centos project]$ ls readme src [jerry@centos project]$ cd src/

[jerry@centos src]$ git add makefile [jerry@centos src]$ git mv string.c string_operations.c

[jerry@centos src]$ git status -s a makefile r string.c −> string_operations.c

git 是顯示r在檔案之前名稱來指示檔案已更名。

對於提交操作jerry 使用 -a標誌,這使得git 提交自動檢測修改過的檔案。

[jerry@centos src]$ git commit -a -m 『added makefile and renamed strings.c to string_operations.c 『

[master 94f7b26] added makefile and renamed strings.c to string_operations.c 1 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/makefile rename src/ (100%)

提交後,他推送了他的修改到版本庫。

[jerry@centos src]$ git push origin master

上面的命令會產生以下結果。

counting objects: 6, done. compressing objects: 100% (3/3), done. writing objects: 100% (4/4), 396 bytes, done. total 4 (delta 0), reused 0 (delta 0) to [email protected]:project.git 7d9ea97..94f7b26 master −> master

現在,其他開發人員可以通過更新他們的本地資源庫中的這些修改。

Git 重新命名操作

截至目前,tome 和jerry 都使用手動命令來編譯自己的專案。jerry 決定為他們的專案建立 makefile,並給予適當的名稱來命名 string.c 檔案。jerry centos project pwd home jerry jerry repo project jerry centos...

git 分支重新命名

1.本地分支重新命名 git branch m oldbranchname newbranchname 2.遠端分支重新命名 假設本地分支和遠端對應分支名稱相同 a.重新命名遠端分支對應的本地分支 git branch m old local branch name new local branch...

git 分支重新命名

假設分支名稱為oldname 想要修改為 newname 1.本地分支重新命名 還沒有推送到遠端 git branch m oldname newname2.遠端分支重新命名 已經推送遠端 假設本地分支和遠端對應分支名稱相同 git push delete origin oldnamegit bra...