Herramientas de usuario

Herramientas del sitio


wiki2:gitcommands

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
wiki2:gitcommands [2018/08/27 18:55]
alfred [Merges]
wiki2:gitcommands [2020/06/16 12:26] (actual)
Línea 82: Línea 82:
 </​code>​ </​code>​
  
 +==== Undo last commit ====
 +<​code>​
 + git reset HEAD~ 
 +</​code>​
 +
 +==== Unstage changes ====
 +<​code>​
 +git rm --cached -r -- .
 +</​code>​
 +
 +===== Reset =====
 +==== Reset a full repo ====
 +<​code>​
 +git reset --hard HEAD
 +git clean -f -d
 +</​code>​
 +
 +==== Reset a single file ====
 +<​code>​
 +git checkout filename
 +</​code>​
 +
 +==== Reset a file with the same name as a branch ====
 +
 +<​code>​
 +git checkout -- filename
 +</​code>​
 +
 +==== Remove not tracket files ====
 +<​code>​
 +git clean -f -d 
 +</​code>​
 ===== Branches ===== ===== Branches =====
   * Create new branch: ''​git checkout -b [name_of_your_new_branch]''​   * Create new branch: ''​git checkout -b [name_of_your_new_branch]''​
Línea 95: Línea 127:
 </​code>​ </​code>​
  
-==== Eliminar branch ​local ====+==== Eliminar branch ==== 
 +=== Local ===
  
 <​code>​ <​code>​
 git branch -D no_queues git branch -D no_queues
 +</​code>​
 +
 +=== Remota ===
 +
 +<​code>​
 +git push origin --delete test
 </​code>​ </​code>​
  
Línea 127: Línea 166:
  
 Upload tags to the remote: ''​git push origin --tags ''​ Upload tags to the remote: ''​git push origin --tags ''​
 +
 +Remove a tag:
 +<​code>​
 +git push --delete origin <​tagname>​
 +</​code>​
 ===== Push over a non-bare repo ===== ===== Push over a non-bare repo =====
 You need to set denyCurrentBranch You need to set denyCurrentBranch
Línea 164: Línea 208:
 In case you've made a mistake while resolving a conflict and realize this only after completing the merge, you can still easily undo it: just roll back to the commit before the merge happened with ''​git reset --hard ''​ and start over again. In case you've made a mistake while resolving a conflict and realize this only after completing the merge, you can still easily undo it: just roll back to the commit before the merge happened with ''​git reset --hard ''​ and start over again.
  
 +
 +===== Bundle =====
 +
 +Create a bundle file:
 +<​code>​
 +git bundle create your_name.bundle --all
 +</​code>​
 +Use it:
 +<​code>​
 +git clone <​path_to_bundle_file>​
 +</​code>​
 ===== Fixing ===== ===== Fixing =====
 ==== A detached head ==== ==== A detached head ====
 +
 +https://​stackoverflow.com/​a/​14757539
 +
 If you type ''​git reflog'',​ it will show you the history of what revisions ''​HEAD''​ pointed to. Your detached head should be in there. Once you find it, do ''​git checkout -b my-new-branch abc123''​or ''​git branch my-new-branch abc123''​ (where ''​abc123''​ is the SHA-1 of the detached HEAD) to create a new branch that points to your detached head. Now you can merge that branch at your leisure. If you type ''​git reflog'',​ it will show you the history of what revisions ''​HEAD''​ pointed to. Your detached head should be in there. Once you find it, do ''​git checkout -b my-new-branch abc123''​or ''​git branch my-new-branch abc123''​ (where ''​abc123''​ is the SHA-1 of the detached HEAD) to create a new branch that points to your detached head. Now you can merge that branch at your leisure.
  
Línea 200: Línea 258:
 </​code>​ </​code>​
  
 +Other easier:
 +<​code>​
 +git remote add gitea https://​git.alfredgg.dev/​gtd/​docker-without-pants.git
 +git push gitea
 +</​code>​
 ==== Use git from another folder ==== ==== Use git from another folder ====
 <​code>​ <​code>​
Línea 209: Línea 272:
 <​code>​ <​code>​
 git config --global credential.helper 'cache --timeout 86400' git config --global credential.helper 'cache --timeout 86400'
 +</​code>​
 +
 +<​code>​
 +git config credential.helper store
 +</​code>​
 +==== Gitlab beginning ====
 +
 +Git global setup
 +<​code>​
 +git config --global user.name "​user1"​
 +git config --global user.email "​user1@test.com"​
 +</​code>​
 +Create a new repository
 +<​code>​
 +git clone http://​127.0.0.1/​user1/​test.git
 +cd test
 +touch README.md
 +git add README.md
 +git commit -m "add README"​
 +git push -u origin master
 +</​code>​
 +Existing folder
 +<​code>​
 +cd existing_folder
 +git init
 +git remote add origin http://​127.0.0.1/​user1/​test.git
 +git add .
 +git commit -m "​Initial commit"​
 +git push -u origin master
 +</​code>​
 +Existing Git repository
 +<​code>​
 +cd existing_repo
 +git remote rename origin old-origin
 +git remote add origin http://​127.0.0.1/​user1/​test.git
 +git push -u origin --all
 +git push -u origin --tags
 </​code>​ </​code>​
wiki2/gitcommands.1535396137.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)