GIT practical commands Flashcards
Learn most used git commnds
How to see changes on current branch?
$ git status
How to switch to other branch?
$ git checkout branchName
How to see differences between current and some other branch?
$ git diff myFeaturBranch
How to do merge with no “fast-forward” to preserve branch history?
$ git merge –no-ff myFeaturBranch
Git command to do rebase
$ git rebase branchToRebaseOn
Describe rebasing procedures
$ git checkout myfeatureBranch
$ git rebase develop
$ git push –force
When rebacsing you should be on a branch on which you want to rebase or branch which you rebase?
You should be on branch you want to rebase
$ git rebase develop
Will rebase current branch on develop.
How to see remote branches?
$ git branch -r
How to see all (remote and local) branches?
$ git branch -a
What is stale branch?
Stale branch: a remote tracking branch which doesn’t track anything (because the actual branch on the remote repo is gone)
How to remove stale branches?
$ git remote prune origin
How to remove branch from the remote repo
$ git branch -d -r origin/mybranch
After resolving rebase conflict which command should be run to continue rebase?
$ git rebase –continue
How to merge only one file from another branch?
switch to the branch to which you want to marge file.
$ git checkout branchToTakeFileFrom file/path.js
How to merge multiple file from another branch?
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