Sunday, September 10, 2017

Git - Commands


     
  •  Suppose $COMMIT_id  was the last commit id before you performed git pull. What you need to undo the last pull is         

                    git reset --hard $COMMIT_id 
  •  git diff   -   Show unstaged changes between your index and working directory.                                                                                                                                          
  •  git pull    -    This update whole  branches of  local  repository   .                                                                                                                                                                                  
  •  The git pull  command is actually a combination of two other commands, git fetch  followed by git merge ,
    it does a git fetch and then a git merge where it merges branches that have been setup to be merged in your config
                  git fetch just "downloads" the changes from the remote to your local repository. git pull downloads the changes and merges them into your
                  current branch. "In its default  mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD
  • If you want to  get a file( src/main/resources/application-dev.properties) from another branch (master)  to your current working branch then,                                                                               
                  git checkout dev
                  git pull origin  dev
                  git checkout  master -- src/main/resources/application-dev.properties                                                   
  • To remove last commit
     git pull origin  dev
    git reset --hard HEAD~1  //Remove last commit ,1  means one last commit, if  it  is  2,then last two commits gitk git push       origin dev --force
  •  To change commit message  use command ,
     $ git commit --amend
     Then window that will open , change message .Then click Esc  button and type :wq
     Finally push changes.
     
  • If you are currently working on local branch master, and the new remote branch has not been created yet:


    git checkout -b new_branch_name //Creates a local branch(as a copy of the current)
    git push origin new_branch_name //Push it to the remote server 
     
     
     
     
     
     
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    Image result for git  local operations of reset 
     
     
     Image result for git  local operations of reset
    
    
 
 
 

No comments:

Post a Comment

The AI Driven Software Developer, Optimize Innovate Transform

  The AI-Driven Software Developer: Optimize, Innovate, Transform": AI Transformation in Software Development : Understand how AI is re...