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
Last revisionBoth sides next revision
linux:git [2020/06/05 10:02] – [Basic usage] tmadelinux:git [2024/04/16 16:49] – [Commands] tmade
Line 11: Line 11:
  
   git init                                       #Initialize repository in actual working directory   git init                                       #Initialize repository in actual working directory
-  git config --global user.name "Your Name"      #Set your account's default identity+  git config --global user.email "you@example.com" 
 +  git config --global user.name "Your Name"      #Set your account's default identity                              # stored in ~home/<username>/.gitconfig 
   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+  git status                                     #Show which files tracked and active branch 
 +  git tag --list                                 #show tags 
 +  git tag                                        #show tags 
 +  git branch                                     #show acitve branch
   git add file                                   #Add file "file"   git add file                                   #Add file "file"
 +  git rm --cached myfile                         #remove file which was previously added
   git add .                                      #Add all files in working directory   git add .                                      #Add all files in working directory
   git commit -m "initial commit"                 #Commit all files with comment   git commit -m "initial commit"                 #Commit all files with comment
Line 22: Line 27:
   git checkout ID file                           #Revert to change from ID   git checkout ID file                           #Revert to change from ID
   git diff                                       #Show diff/ changes   git diff                                       #Show diff/ changes
 +  git reset --hard HEAD~1                        #remove last commit
 +  git reset --hard HEAD~2                        #remove 2 commits
 +  git reset --hard                               #
 +  git checkout -b branch-name                    #creates "local" branch, which will be uploaded by "git pull"
 +  tag = read only branch nie wieder veränderbar/ version
 +  git tag --list
 +  git branch --list
 +  git checkout <existing_branch>                 #change branch
 +  git checkout -b <new_branch>
 +  git log -- path/to/file
 +  
 +Tag: Readonly version of master (version). Tags give the ability to mark specific points in history as being important.
 +
 +Revert:
 +  git reset --hard commit-ID
 +  git commit -m "revert"
 +  
 +
 +====scripts====
 +
 +Push:
 +<code>
 +root@kmaster:/scripts# cat git-push.sh
 +#/bin/bash
 +
 +read -p "Please enter commit message: " COMMIT
 +echo "Commit message:  \"$COMMIT\""
 +
 +git add .
 +git commit -m "${COMMIT}"
 +#git commit -m update
 +git push -u origin master
 +</code>
  
 ==== Konfiguration ==== ==== Konfiguration ====
Line 55: Line 93:
   eval $(ssh-agent -s)   eval $(ssh-agent -s)
   ssh-add /home/myuser/.ssh/id_rsa   ssh-add /home/myuser/.ssh/id_rsa
-  git remote add gitlab git@git.local:myuser/kubernetes.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/icinga.git+  git remote add origin ssh://git@hostname:8822/tmade/myrepo.git 
 +  git remote set-url origin ssh://git@hostname:8822/tmade/myrepo.git   #rename origin
   git remote                                                           #check, if remote location exists (test/ prod)   git remote                                                           #check, if remote location exists (test/ prod)
   git remote -v   git remote -v
Line 62: Line 101:
   git add .                                                            #or "git add kubeadm-config.yaml"   git add .                                                            #or "git add kubeadm-config.yaml"
   git commit -m "initial commit"                                       #to the previously created project on e. g. gitlab   git commit -m "initial commit"                                       #to the previously created project on e. g. gitlab
-  git push gitlab master                                               #gitlab target-server+  git push gitlab master                                               #update changes to master 
 +  git pull origin master                                               #pull changes from master
linux/git.txt · Last modified: 2024/04/16 17:38 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