Check if Git has already been installed, Git is usually preinstalled on Mac and Linux.
Type the following command and then press enter: Tell Git who you are First, you need to tell Git who you are:
git config –global user.name “Your Name”
Some basic Git operations
When we worked on GitHub, the basic work cycle like the fork, edit, commit, pull request, merge. The same cycle, with a few differences, is what we will work through on the command line.
Getting the current branch
# On branch master
nothing to commit (working directory clean)
Merge code from remote branch called dev to local user alex
git checkout alex
git merge dev
Merge code from local alex to remote branch
git merge alex
git checkout alex
git branch commands’ various options. -a shows all local and remote branches, while -r shows only remote branches.
Show all local and remote branch
Show all remote branch
There’s also another way to do figure out what branches are on your remote by actually using the remotely related commands, git remote and git ls-remote. The former displays plenty of information about the remote in general and how it relates to your own repository, while the latter simply lists all references to branches and tags that it knows about.
$ git ls-remote --heads origin
Conflict Merge error
While merging file from master to local alex branch, sometime we may cause conflict merge error. We can solve the conflicted merge error in the number of ways. If we want to merge conflict file to remote master file then we can use git command.
Reset last committed or undo: The 1st command will Undo local and second will force delete from remote
git push -f
Check Last two week commits
Undo the git merge that has not committed yet: first check git log. You can use