GIT practical commands Flashcards

Learn most used git commnds

1
Q

How to see changes on current branch?

A

$ git status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to switch to other branch?

A

$ git checkout branchName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to see differences between current and some other branch?

A

$ git diff myFeaturBranch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to do merge with no “fast-forward” to preserve branch history?

A

$ git merge –no-ff myFeaturBranch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Git command to do rebase

A

$ git rebase branchToRebaseOn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe rebasing procedures

A

$ git checkout myfeatureBranch
$ git rebase develop
$ git push –force

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When rebacsing you should be on a branch on which you want to rebase or branch which you rebase?

A

You should be on branch you want to rebase
$ git rebase develop
Will rebase current branch on develop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to see remote branches?

A

$ git branch -r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to see all (remote and local) branches?

A

$ git branch -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is stale branch?

A

Stale branch: a remote tracking branch which doesn’t track anything (because the actual branch on the remote repo is gone)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to remove stale branches?

A

$ git remote prune origin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to remove branch from the remote repo

A

$ git branch -d -r origin/mybranch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

After resolving rebase conflict which command should be run to continue rebase?

A

$ git rebase –continue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to merge only one file from another branch?

A

switch to the branch to which you want to marge file.

$ git checkout branchToTakeFileFrom file/path.js

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to merge multiple file from another branch?

A

To merge multiple files include path to each file separated by space.
$ git checkout master path/to/file/a.js path/to/file/b.js path/to/file/s.js

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to rename current branch

A

$ git branch -m newName

17
Q

How to rename not a current branch

A

$ git branch -m currentName newName