Monday, October 21, 2013

Common git commands:


1. To cut a new branch from an existing one
       • git checkout -b "branch name"

2. To push the above created branch
       • git push –u origin “branch name”

3. To rename a branch 
       • git branch –m “old name” “new name”

4. To remove all the commits 
       • git reset –hard origin/branchName

5. To delete a branch (First remove remote)
       • git push origin :branchName

6. To delete a branch (Then Locally)
       • git branch –d branchName
       • git branch –D branchName (Forcefully)

7. To remove a file from staging area
       • git reset HEAD fileName

8. To remove commit 
  • git reset --hard HEAD
then
  • git push origin HEAD --force 

No comments:

Post a Comment