Monday, May 9, 2016

GIT Interview questions

checkout the master

=> git clone  url
This above command will get the repo into your local 


Now , we get the folder from the rul
An example of this is as follows

Now check the branch you are on using 
=> git branch
We will see master*
we are on the master
Create a new branch  test using the following
=>  git branch test
=>  git branch
=>  git checkout test
=>  git branch
Now we will see
master
test*
The current branch is test
Now switch to the master branch

=>git checkout master

git branch
master*
test

======================MERGE - 2 WAYS===============================
=>git checkout test
=>git commit -m "test commit1"

=>git checkout master
=>git commit -m "master commit1"
=> git branch
  master*
  test
=>git merge test

The above command will merge test into the branch we are currently on , which is the master branch

===================== Rebase =====================================
The second way of combining work between branches is rebasing. Rebasing essentially takes a set of commits, "copies" them, and plops them down somewhere else.
While this sounds confusing, the advantage of rebasing is that it can be used to make a nice linear sequence of commits. The commit log / history of the repository will be a lot cleaner if only rebasing is allowed.
Let's see it in action..
URL : http://pcottle.github.io/learnGitBranching/


















No comments: