inner-banner

Blog

Home Blog

Git Tutorials - Part 2

November 21, 2017 | Ajinkya Dube |

img

With respect to my previous blog on basic git commands, I am listing some intermediate level Git commands.

Ref: [git-tutorials](http://starkdigital.net/git-tutorials)

1. Fetch all branched locally.

> git fetch

2. Remove a file from git repo.

> git rm {file path}

3. Remove untracked files from repo which are not in use.

> git clean -df

4. Merge branch in parent branch.

> git merge {parent branch}

5. Create a tag for a branch.

> git tab -a {Tag Name} -m {Tag Description}

6. Push local tags.

> git push origin --tags

7. Show list of previous commits.

> git log

8. Rollback to the last commit. We can use this command if we have written some unwanted code but now we don't want it. Use with precaution.

> git reset --hard HEAD

9. Rollback to a specific commit.

> git reset --haed {commit id}

10. Most dangerous: forcefully rollback to older commit of a branch. Note: Don't take pull in between 2 commands.

> git reset --hard {commit id}
> git push origin {branch name} -f

So these are some commands we can use for getting hands on git. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter or Facebook.

About the author

blog-author

Ajinkya Dube