So you have just started using the Bitbucket git repository what should you pick up next?

Saurav Rai
3 min readMay 22, 2022

I have been using bit-bucket for a year and I found git commands incredibly helpful. So here is a list of the most git commands that will make our life easier. But the first thing you haven’t yet set up your ssh keys to your bit-bucket repository, then you can check the link mentioned below to do the same.

Great! now if you have everything set up, configure Git for the first time using the following commands.

git config — global user.name “Your user name”
git config — global user.email “Your mail id”

Now clone your git repository using the following command

git clone ssh://link_to_your_bit_bucket_repository.git

Alright, we are ready to discuss various git commands. Now, let us discuss the git commands.

git checkout <branchname> to switch from one branch to another branch.

  1. git checkout <commit hash> to go to a particular commit
  2. git checkout <branchname> after checking out to a different commit number, to get back to the head
  3. git add <relative path to the file name/folder> for adding files to the BitBucket repository
  4. git commit -m “message” for committing to the BitBucket repository
  5. git push -u origin <branchname> for pushing the changes to the branch
  6. git log -N to check the last N commits in a particular branch
  7. git status to check the state of the branch before making any changes in the repository (Good Practice!!)
  8. git branch to check the list of branches in the BitBucket
  9. git reset — hard to clear all the changes made since the last commit (permanently remove any uncommitted changes)
  10. git clean -f add_to_file to clear all the untracked files
  11. git pull origin branchname to get changes only from a particular branch
  12. git mv {source location} {Destination location} to move the files from the source to the destination location
  13. git rm -r {Directory_name} for deleting the files or a directory
  14. git checkout -b {New_branch_name} for creating a new branch
  15. git fetch to take out all the recent changes in the git repository
  16. git branch -r To see the all the branches
  17. git reset — hard head~1 (1 means the last commit ) removes the local commits that have not been pushed in the BitBucket
  18. git revert commit_no for reverting the last commit
  19. There are two ways to delete a stash. If you no longer need a particular stash, you can delete it with: git stash drop <stash_id> .
    You can either delete all of your stashes with: git stash clear.

So these are the commands that I have been using for a year and found extremely handy. Kindly note that this page is a work in progress and will be updated as I gain more familiarity and experience with the BitBucket. My understanding of best practices are likely to evolve, and the recommendations on this page will be updated to reflect that. I hope this page will be of beneficial to some individuals for getting started. With that I sign off. Cheers and Happy Learning :)

To download git for windows: Use the link Git for Windows

--

--