Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:git [2024/09/24 15:39] – [Commands] tmadelinux:git [2026/07/16 13:09] (current) – [Commands] tmade
Line 15: Line 15:
   git config user.name "Your Name"                         #Set the identity only in this repository   git config user.name "Your Name"                         #Set the identity only in this repository
   git status                                               #Show which files tracked and active branch   git status                                               #Show which files tracked and active branch
 +  git add .                                                #or "git add kubeadm-config.yaml"
 +  git commit -m "initial commit"                           #to the previously created project on e. g. gitlab
 +  git commit -am "my message"                              #add + commit at once, but just for already staged files in repo. New files have to be added first via "git add file" or "git add ."
 +  git push gitlab master                                   #update changes to master
 +  git pull origin master                                   #pull changes from master
   git tag --list                                           #show tags   git tag --list                                           #show tags
   git tag                                                  #show tags   git tag                                                  #show tags
Line 20: Line 25:
   git add file                                             #Add file "file"   git add file                                             #Add file "file"
   git rm --cached myfile                                   #remove file which was previously added   git rm --cached myfile                                   #remove file which was previously added
-  git add .                                                #Add all files in working directory 
-  git commit -m "initial commit"                           #Commit all files with comment 
   git log                                                  #Show history   git log                                                  #Show history
   git revert ID                                            #Revert to change from ID - other changes after not affected   git revert ID                                            #Revert to change from ID - other changes after not affected
Line 29: Line 32:
   git reset --hard HEAD~2                                  #remove 2 commits   git reset --hard HEAD~2                                  #remove 2 commits
   git checkout -b branch-name                              #creates "local" branch, which will be uploaded by "git pull"   git checkout -b branch-name                              #creates "local" branch, which will be uploaded by "git pull"
 +  git push origin --delete <branch-name>                   #delete remote branch
 +  git branch -d <branch-name>                              #delete lokal branch
   tag = read only branch nie wieder veränderbar/ version   tag = read only branch nie wieder veränderbar/ version
   git tag --list   git tag --list
   git branch --list                                        #show local branches   git branch --list                                        #show local branches
   git branch --all                                         #show all branches and remote   git branch --all                                         #show all branches and remote
 +  git branch -D branch                                     #Note: -D is a shortcut for --delete --force. First switch to another branch!
   git fetch --prune                                        #update remote branches and also delete branches not existing on repository anymore   git fetch --prune                                        #update remote branches and also delete branches not existing on repository anymore
   git fetch                                                #update remote branches   git fetch                                                #update remote branches
Line 47: Line 53:
      
  
 +Rebase:
 +
 +  git commit                                                            #if there was a change
 +  git rebase -i HEAD~4                                                  #4 commmits backwards
 +  git rebase -i ffa3fb36cf62ea41824b781b681c7e753d2406ee~ (commit ID)   #back inclusive last commit through "~" at the ende of commit-ID
 +  git rebase -i ffa3fb36cf62ea41824b781b681c7e753d2406ee (commit ID)    #back exclusive last commit 
 +  git push -f
 ====scripts==== ====scripts====
  
Line 94: Line 107:
 </code> </code>
  
-===Remote git===+====Remote git====
  
-  eval $(ssh-agent -s) 
-  ssh-add /home/myuser/.ssh/id_rsa 
   git remote add gitlab git@git.local:myuser/myrepo.git                #"gitlab" = name you can choose   git remote add gitlab git@git.local:myuser/myrepo.git                #"gitlab" = name you can choose
-  git remote add origin ssh://git@hostname:8822/tmade/myrepo.git +  git remote add origin ssh://git@hostname:8822/tmade/myrepo.git       #add origin 
-  git remote set-url origin ssh://git@hostname:8822/tmade/myrepo.git   #rename origin+  git remote set-url origin ssh://git@hostname:8822/tmade/myrepo.git   #rename target repo
   git remote                                                           #check, if remote location exists (test/ prod)   git remote                                                           #check, if remote location exists (test/ prod)
   git remote -v   git remote -v
   git remote remove origin                                             #remove remote "origin"   git remote remove origin                                             #remove remote "origin"
-  git add .                                                            #or "git add kubeadm-config.yaml" +  git remote rename origin old-origin                                  #renmame origin name to old-origin 
-  git commit -m "initial commit"                                       #to the previously created project on e. g. gitlab + 
-  git push gitlab master                                               #update changes to master +  git push --set-upstream origin --all 
-  git pull origin master                                               #pull changes from master+  git push --set-upstream origin --tags
  
 ==== .gitignore ==== ==== .gitignore ====
linux/git.1727185181.txt.gz · Last modified: by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki