101 lines
2.0 KiB
Org Mode
101 lines
2.0 KiB
Org Mode
#+DATE: 2023-06-04
|
|
#+EMAIL: greenleaves@disroot.org
|
|
#+OPTIONS: num:nil toc:2
|
|
#+PROPERTY: header-args:bash :results output :session *bashgit* :tangle yes
|
|
#+PROPERTY: header-args:bash+ :exports both :dir ./scratch
|
|
|
|
* Remotes
|
|
|
|
#+begin_example bash
|
|
git remote -v
|
|
#+end_example
|
|
|
|
Add a remote
|
|
|
|
#+begin_example bash
|
|
git remote add pb https://gitdisroot.org/new_repo.git
|
|
#+end_example
|
|
|
|
Fetching information from remote
|
|
|
|
#+begin_example bash
|
|
git fetch pb
|
|
|
|
git pull
|
|
#+end_example
|
|
|
|
Inspecting remote
|
|
|
|
#+begin_example bash
|
|
git remote show origin
|
|
#+end_example
|
|
|
|
Changing remote url
|
|
|
|
#+begin_src bash
|
|
git remote set-url origin https://repo.multifarm.top/multigranja/bash_tutorial.git
|
|
#+end_src
|
|
|
|
Removing a remote url
|
|
|
|
#+begin_example bash
|
|
git remote rm origin
|
|
#+end_example
|
|
|
|
|
|
Addig a remote to a local git repository:
|
|
|
|
#+begin_example bash
|
|
git remote add origin https://git.disroot.org/user/reponame.git
|
|
#+end_example
|
|
|
|
*** Set the remote as origin
|
|
|
|
First option:
|
|
|
|
#+begin_example bash
|
|
git push --set-upstream origin master
|
|
#+end_example
|
|
|
|
This command will put "master" as upstream branch. If you have another branch
|
|
(let's say "main"), the command will create a new branch named "master". After
|
|
This process you will need to create a pull request and then merge one branch
|
|
into the other.
|
|
|
|
#+begin_example bash
|
|
git pull origin master --allow-unrelated-histories
|
|
git merge origin origin/master
|
|
#+end_example
|
|
|
|
Second option:
|
|
|
|
Set the remote stream (~origin~ on this example) as ~main~ branch:
|
|
|
|
should create a branch called "main", then set as "upstream"
|
|
|
|
#+begin_example bash
|
|
git branch --set-upstream-to=origin/main
|
|
#+end_example
|
|
|
|
After this, you can use:
|
|
|
|
#+begin_example bash
|
|
git pull
|
|
#+end_example
|
|
|
|
And the branch "main" would be used as remote.
|
|
|
|
Optionally you may use the following when you have a new local repository:
|
|
|
|
#+begin_example bash
|
|
git branch -u origin/main
|
|
#+end_example
|
|
|
|
Or use:
|
|
|
|
#+begin_example bash
|
|
git push -u origin main
|
|
#+end_example
|
|
|
|
After this change, you can retrieve and send changes to the remote repository
|