Инструменты пользователя

Инструменты сайта


develop:git

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
develop:git [2023/11/18 06:32]
admin
develop:git [2024/09/06 10:50] (текущий)
admin
Строка 29: Строка 29:
 # Добавить удаленный репозиторий # Добавить удаленный репозиторий
 git remote add <name> (или origin для репы по умолчанию) https://github/uset/repo git remote add <name> (или origin для репы по умолчанию) https://github/uset/repo
 +  # например
 +git remote add origin git@github.com:ncily/gh_actions.git
 +
  
   # Отправка проекта   # Отправка проекта
Строка 173: Строка 176:
 ./execute_on_all_repos.sh git push origin --delete 1854_norm ./execute_on_all_repos.sh git push origin --delete 1854_norm
  # Удалить локальную ветку  # Удалить локальную ветку
-git branch --delete 1854_norm +git branch --delete -D 1854_norm 
-./execute_on_all_repos.sh git branch --delete 1854_norm+./execute_on_all_repos.sh git branch --delete -D 1854_norm
  
  
Строка 210: Строка 213:
  
 <details> <details>
-<summary> :!: </summary>+<summary> :!: Экспорт из GitLab в GitHub</summary> 
 +Работает в т.ч. и как актуализация уже существующего экспорта в GH\\ 
 +[[https://stackoverflow.com/questions/22265837/transfer-git-repositories-from-gitlab-to-github-can-we-how-to-and-pitfalls-i|Source]]\\ 
 +[[https://github.com/piceaTech/node-gitlab-2-github|Source2]]\\
  
 <code bash> <code bash>
 +  # from gitLab
 +git clone --mirror git@your-gitlab-site.com:username/repo.git
 +
 +cd repo
 +  # to gitHub
 +git push --no-verify --mirror git@github.com:username/repo.git
 </code> </code>
 </details> </details>
  
  
 +
 +<details>
 +<summary> :!: </summary>
 +
 +<code bash>
 +</code>
 +</details>
  
  
Строка 326: Строка 345:
  
  
 +<details>
 +<summary>:!: Пример слияния репозиториев</summary>
 +Точнее включение одного репозитория в другой, подпроектом\\
 +
 +<code bash>
 +# Клонируем тот репозиторий, который будет мержиться
 +git clone https://github.com/first-repo
 +cd first-repo
 +git remote rm origin # На всякий случай отвязываем репозиторий 
 + 
 +# Подготавливаем репозиторий: перемещаем всё содержимое репозитория (за исключением папки .git) в отдельную папку, которая и будет подключаться в другой репозиторий
 +mkdir first_repo
 +git mv $(ls -A | grep -v first_repo | grep -v .git) first_repo/ 
 +git commit -m "prepare repo for merging in main_repo - move all to new subdir"
 + 
 +# Клонируем рядом целевой репозиторий
 +cd ..
 +git clone https://github.com/main_repo
 +cd main_repo/
 + 
 +# Подключаем к нему подготовленный первый репозиторий и вытаскиваем его master в отдельную ветку first-repo
 +git remote add first-repo ../first-repoe/
 +git fetch first-repo
 +git branch first-repo remotes/first-repo/master
 + 
 +# Мержим ветку в локальный master
 +git merge first-repo --allow-unrelated-histories
 +git remote rm first-repo
 + 
 +# Проверяем и пушим
 +git log 
 +git push
 +</code>
 +</details>
 +
 +
 +
 +<details>
 +<summary> :!: Cмена Remote</summary>
 +
 +<code bash>
 +git remote -v
 +# View existing remotes
 +# origin  https://github.com/user/repo.git (fetch)
 +# origin  https://github.com/user/repo.git (push)
 +
 +git remote set-url origin https://github.com/user/repo2.git
 +# Change the 'origin' remote's URL
 +
 +git remote -v
 +# Verify new remote URL
 +# origin  https://github.com/user/repo2.git (fetch)
 +# origin  https://github.com/user/repo2.git (push)
 +</code>
 +</details>
  
  
 =====  ===== =====  =====
develop/git.1700289137.txt.gz · Последнее изменение: 2023/11/18 06:32 — admin