Showing posts with label Bitbucket. Show all posts
Showing posts with label Bitbucket. Show all posts

Friday, 2 December 2016

Wednesday, 23 November 2016

Git Issue : Your branch and 'origin/master' have diverged - how to throw away local commits?

22:21:00 Posted by Kumanan ,
I have the following message in git:

# Your branch and 'origin/master' have diverged, 
# and have 3 and 8 different commits each, respectively. 
# (use "git pull" to merge the remote branch into yours) 

I would like to throw away the 3 local commits, and pull the 8 remote commits at origin/master.

git fetch origin 
git reset --hard origin/master

Sunday, 20 November 2016

git pull: There is no tracking information for the current branch - BitBucket Issue

23:42:00 Posted by Kumanan ,
You could specify what branch you want to pull:-

git pull origin master


Or you could set it up so that your local master branch tracks github master branch as an upstream:

git branch --set-upstream-to=origin/master master
git pull


This branch tracking is set up for you automatically when you clone a repository (for the default branch only), but if you add a remote to an existing repository you have to set up the tracking yourself. Thankfully, the advice given by git makes that pretty easy to remember how to do.

Thursday, 10 December 2015

Bitbucket

19:02:00 Posted by Kumanan
Command Lines:-

To check out your branch:
  git fetch && git checkout master

To check the status:-
  git status

To add a file to do commit:-
  git add <file_name>

Undo git add before commit:-
  git reset <file_name>

To commit a file:-
  git commit

To commit a file with a message:-
  git commit -m "<your message>"

To get Branch name:-
  git branch

Create the branch on your local machine and switch in this branch :
  git checkout -b <branch_name>

Switch to other branch in local:-
  git checkout <branch_name>

Create branch in remote:-
  git push <remote_name> <branch_name>

  Note:- The remote branch is automatically created when you push it to the remote server. So when you feel ready for it, you can just do the above.

To get log list:-
  git log
  git shortlog

Total committed count:-
  git shortlog -s

To revert the previous commit:-
  git reset --hard <commit_id>

To get the changes from the remote:-
  git pull

To Clone a branch other than master branch :-
  git clone <remote_name> -b <branch_name>

Difference between 2 branch :-
  git diff <branch_1> <branch_2>

To get the files which has changes between branches :-
  git diff --name-status <branch_1> <branch_2>


To get Git username :-
  git config user.name
  git config --list

To change Git username:-
  git config --global user.name "Alvin J. Alexander"
  git config --global user.email "alexander123@hotmail.com"

To Clone a Specific Git Branch :-
  git clone --single-branch --branch <branchname> <remote-repo>

To view all the branch available :-
  git branch -a