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 [2020/06/05 10:05] – [Basic usage] tmadelinux:git [2024/04/16 17:38] (current) tmade
Line 10: Line 10:
 ==== Commands ==== ==== Commands ====
  
-  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"         #set email 
-  git config user.name "Your Name"               #Set the identity only in this repository +  git config --global user.name "Your Name"                #Set your account's default identity                              # stored in ~home/<username>/.gitconfig  
-  git status                                     #Show which files tracked +  git config user.name "Your Name"                         #Set the identity only in this repository 
-  git add file                                   #Add file "file" +  git status                                               #Show which files tracked and active branch 
-  git add .                                      #Add all files in working directory +  git tag --list                                           #show tags 
-  git commit -m "initial commit"                 #Commit all files with comment +  git tag                                                  #show tags 
-  git log                                        #Show history +  git branch                                               #show acitve branch 
-  git reset --hard                               #Discard changes which are not commited yet +  git add file                                             #Add file "file" 
-  git revert ID                                  #Revert to change from ID - other changes after not affected +  git rm --cached myfile                                   #remove file which was previously added 
-  git checkout ID file                           #Revert to change from ID +  git add .                                                #Add all files in working directory 
-  git diff                                       #Show diff/ changes+  git commit -m "initial commit"                           #Commit all files with comment 
 +  git log                                                  #Show history 
 +  git reset --hard                                         #Discard changes which are not commited yet 
 +  git revert ID                                            #Revert to change from ID - other changes after not affected 
 +  git checkout ID file                                     #Revert to change from ID 
 +  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
linux/git.1591344344.txt.gz · Last modified: 2020/06/05 10:05 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