Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:gitconcepts [2017/09/12 13:15] alfred [Resetting changes] |
wiki2:gitconcepts [2021/10/01 16:19] (actual) |
||
|---|---|---|---|
| Línea 134: | Línea 134: | ||
| git rebase master | git rebase master | ||
| </code> | </code> | ||
| + | Imaginemos que tenemos dos branches. Un master y una feature. Si la feature se separó de la master hace unos commits y se agrega algo a master que ha de ser también añadido a feature podemos hacer un merge, con él los cambios que hay en master se unirán a la feature en el estado actual. Al hacer un rebase lo que se consigue es que la branch feature se coloque justo después del cambio en master, como si se hubiese creado en ese momento. | ||
| + | {{ :wiki2:git:g1171.png?300 |}} | ||
| It applies the commits from the master branch to the feature branch, one by one. Rebasing gives you the opportunity to alter commits if you do them interactively (passing -i parameter): | It applies the commits from the master branch to the feature branch, one by one. Rebasing gives you the opportunity to alter commits if you do them interactively (passing -i parameter): | ||
| <code> | <code> | ||
| Línea 147: | Línea 149: | ||
| The stash is a temporary area working like a stack. You can push changes onto it via ''git stash'' or ''git stash save''; you can pop changes from top with ''git stash pop''. You can also apply a very specific part of the stack with ''git stash apply <stash id>''. Finally you can get the list of all the stashes with ''git stash list''. | The stash is a temporary area working like a stack. You can push changes onto it via ''git stash'' or ''git stash save''; you can pop changes from top with ''git stash pop''. You can also apply a very specific part of the stack with ''git stash apply <stash id>''. Finally you can get the list of all the stashes with ''git stash list''. | ||
| + | |||
| + | ===== Cherry pick ===== | ||
| + | |||
| + | Es coger un commit, el que sea (no importa la branch), y aplicar lo que se aplica en él en el estado actual del repositorio. Por ejemplo para aplicar únicamente uno: | ||
| + | <code> | ||
| + | $ git cherry-pick E | ||
| + | </code> | ||
| + | Para aplicar varios cambios: | ||
| + | <code> | ||
| + | $ git cherry-pick C D E | ||
| + | </code> | ||
| + | |||
| + | ===== Git Hooks ===== | ||
| + | |||
| + | En la carpeta ''.git/hooks'' se encuentran scripts para distintos eventos que ocurren durante el uso de git. Si no llevan la extensión ''.sample'' y son ejecutables, se ejecutarán según el momento. | ||
| ===== Servers ===== | ===== Servers ===== | ||
| Línea 157: | Línea 174: | ||
| <code> | <code> | ||
| git remote -v | git remote -v | ||
| + | </code> | ||
| + | |||
| + | ===== Subtrees ===== | ||
| + | |||
| + | Subtrees are an alternative to submodules. | ||
| + | |||
| + | ==== Links ==== | ||
| + | |||
| + | https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec | ||
| + | |||
| + | https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree | ||
| + | |||
| + | https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/ | ||
| + | |||
| + | https://www.youtube.com/watch?v=t3Qhon7burE | ||
| + | ==== Basic operations ==== | ||
| + | === Add a subtree to the current project === | ||
| + | |||
| + | <code> | ||
| + | # Add the new remote to the project | ||
| + | git remote add -f <remote name> <remote address> | ||
| + | # Attach the new code | ||
| + | git subtree add --prefix <folder> <remote name> <branch> --squash | ||
| + | </code> | ||
| + | |||
| + | Example: | ||
| + | <code> | ||
| + | git remote add -f cc_lib http://gitea.codi.coop/codi.cooperatiu/cc_lib.git | ||
| + | git subtree add --prefix cc_lib cc_lib master --squash | ||
| + | </code> | ||
| + | |||
| + | === Pull from remote === | ||
| + | <code> | ||
| + | git fetch <remote name> | ||
| + | git subtree pull --prefix <path> <remote name> <branch> --squash | ||
| + | </code> | ||
| + | |||
| + | Example | ||
| + | <code> | ||
| + | git fetch tpope-vim-surround master | ||
| + | git subtree pull --prefix .vim/bundle/tpope-vim-surround tpope-vim-surround master --squash | ||
| + | </code> | ||
| + | |||
| + | === Update the remote === | ||
| + | //Remind to commit before!!// | ||
| + | <code> | ||
| + | git remote add <remote_name> <remote_address> | ||
| + | git subtree push --prefix=<path> <remote name> <branch> | ||
| + | </code> | ||
| + | |||
| + | Example: | ||
| + | <code> | ||
| + | git remote add cc_lib http://gitea.codi.coop/codi.cooperatiu/cc_lib.git | ||
| + | git subtree push --prefix=cc_lib cc_lib master | ||
| </code> | </code> | ||
| ===== Notes ===== | ===== Notes ===== | ||
| + | |||
| + | GitLab's **"merge request"** feature is equivalent to GitHub's** "pull request"** feature. Both are means of pulling changes from another branch or fork into your branch and merging the changes with your existing code. They are useful tools for code review and change management. | ||
| + | |||
| + | |||
| ==== Inner architecture ==== | ==== Inner architecture ==== | ||
| Everything stored in git is in a file. When you create a commit it creates a file containing your commit message and associated data (name, email, date/time, previous commit, etc) and links it to a tree file. The tree file contains a list of objects or other trees. | Everything stored in git is in a file. When you create a commit it creates a file containing your commit message and associated data (name, email, date/time, previous commit, etc) and links it to a tree file. The tree file contains a list of objects or other trees. | ||
| Línea 176: | Línea 251: | ||
| * https://www.atlassian.com/git/tutorials/gitignore/ | * https://www.atlassian.com/git/tutorials/gitignore/ | ||
| - | ==== Use meld for UI for merging ==== | + | ==== Problems with certificates ==== |
| + | |||
| + | You can solve them by [1] [[wiki2:linux_howto#update_system_certificate_authority|updating the certificate authority]] or [2] ''export GIT_SSL_NO_VERIFY=1'' or [3] ''git config --global http.sslverify false''. | ||
| - | To use it for the current repo: | ||
| - | <code> | ||
| - | $ git mergetool -t meld | ||
| - | </code> | ||
| - | To configure git to remember which merge tool you want, type git config –global merge.tool [tool]. For meld use: | ||
| - | <code> | ||
| - | $ git config --global merge.tool meld | ||
| - | </code> | ||