Friday, January 12, 2018

GIT commands

GIT commands help:

List of Branches:
    git branch -a
    
* master                                  //* means current branch in your local system
  remotes/origin/HEAD -> origin/master
  remotes/origin/master    

Create a branch:
  git branch NEW_BRANCH_LOCALLY
  
List of branches again:
  git branch -a
  NEW_BRANCH_LOCALLY
* master                                  //* means current branch in your local system
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  
Rename a GIT branch (Locally and Remotely):
    git branch -m old_branch new_branch         # Rename branch locally.    
    git push origin :old_branch                 # Delete the old branch from remote.
    git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote.

Delete a Branch in GIT:
    git branch -d THE_LOCAL_BRANCH      (Delete local branch).
    git push origin :THE_REMOTE_BRANCH  (Delete Remote branch).
    or
    git push origin --delete THE_REMOTE_BRANCH 

Sync your Local branches with Remote (Update):
    git fetch -p     
    git fetch THE_REMOTE_BRANCH


Switch branch in local system:
    git checkout THE_LOCAL_BRANCH
Switched to branch 'THE_LOCAL_BRANCH'    
    
    
Commit to a branch in GIT remote:
    git push -u origin 2B_BLOB
    git push origin 2B_BLOB

Commit changes to master branch in GIT remote:    
    git push -u origin master    


Create new branch in GIT remote:
    git remote add 2B_BLOB
    

Merge Request:
    git merge THE_REMOTE_BRANCH/master


Add changes:
git add *      or FILE_NAME

Commit:
git commit -m "Message"

Status:
git status

No comments:

Post a Comment