git添加遠程倉庫與更新遠程倉庫實現(xiàn)方式
1、添加遠程倉庫
要添加一個新的遠程倉庫,可以指定一個簡單的名字,以便將來引用,
運行 git remote add [shortname] [url]:
$ git remote origin $ git remote add pb git://github.com/paulboone/ticgit.git $ git remote -v origin git://github.com/schacon/ticgit.git
pb git://github.com/paulboone/ticgit.git現(xiàn)在可以用字串 pb 指代對應的倉庫地址了。
比如說:要抓取所有 Paul 有的,但本地倉庫沒有的信息,可以運行 git fetch pb:
pb 是git push 命令中的 <遠程主機名>,當把本地master分支的更新推送到遠程主機,可以使用:
git push pb master
2、git push origin master
(第一次請加上參數(shù)-u,代表關聯(lián)本地與遠程) 意思是將本地的master分支推送到遠程庫(origin代表遠程庫)
git push命令用于將本地分支的更新,推送到遠程主機。
它的格式與git pull命令相似。
$ git push <遠程主機名> <本地分支名>:<遠程分支名>
3、把某次commit合入當前分支
git cherry-pick <commit-id>
轉移一系列的連續(xù)提交(包含起始commit)
git cherry-pick <起始 commit 的 SHA-1 值>^..<結束 commit 的 SHA-1 值>
4、查看所有的歷史commit
git reflog // 即reference log 可以參考的log
5、"detached HEAD" state
a "detached HEAD" state refers to a situation where you are no longer on a branch, but instead you are directly pointing to a specific commit. When you are in a detached HEAD state, any changes you make will not be associated with a branch, and if you create a new commit, it will not be part of any branch.
# Your branch is ahead of 'origin/<branch_name>' by 2 commits. # (use "git push" to publish your local commits)
查看本地分支比遠程分支多出的commit:
git log origin/<branch_name>..<branch_name>
總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Git配置之設置用戶名(user.name)和郵箱(user.email)方式
文章介紹了如何在Git中配置全局用戶名和郵箱,以確保所有倉庫使用統(tǒng)一的配置,配置命令包括設置全局用戶名和郵箱,并通過查詢配置來驗證設置是否成功2026-02-02
一文詳解VSCode安裝配置使用(最新版超詳細保姆級含插件)
安裝VScode就很簡單了,一路NEXT就可以了,重點是配置使用以及插件推薦,這篇文章主要給大家介紹了關于VSCode安裝配置使用的相關資料,本文是最新版超詳細保姆級含插件,需要的朋友可以參考下2023-05-05
解決HTTP服務響應數(shù)據(jù)不完整響應數(shù)據(jù)截斷的問題
這篇文章主要介紹了HTTP服務響應數(shù)據(jù)不完整響應數(shù)據(jù)截斷的問題及解決方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-03-03

