I thought I'd put together handy Git commands that I normally use on regular basis. I hope this will help you be more productive in developing your app or managing your codebases.
`git clone <LinkToGitHubRepo>`, creates a local copy of the repository
`git pull`, fetches and merges changes from the remote branch to local branch
`git branch -vv`, checks the local branch's upstream
`git checkout <FirstSevenCharactersOfSHAID> -b <LocalBranchName>`, ** -b creates a new local branch, checks out a particular revision using Git SHAID. I usually use the SHAID as the Branch Name when running tests.
`git revert <ShaID>`, reverts a particular commit SHA
`git checkout --<NameOfFile>`, checks out the original file from the remote branch
`git reset --hard HEAD`, resets the local branch to it’s original state
`git blame <NameOfFile>` , go to the line(s) of code that you are tracing the history of, git will show you the author’s credential and the SHAID.
** Fetch (`git fetch`) the latest code to see the latest committer.
`git log --grep=”<keyword>”`
`git log --grep="<ProjectIDHere>"`, returns any related commit to that particular Project ID (Project Management App ID)
`git log --author="<NameofTeamMemberHere>"`, returns any related commit that person checked in that repository (checkout --since to add filter)
`git rebase -i`, follow the prompt to accomplish your objective. I normally use this to squash multiple local commits into a single commit prior to committing to the central repository
If you want to understand the fundamentals and strategies, this is the book that I read and would recommend "Version Control with Git" by O'Reilly Media. However, there are many more new commands that have been implemented since. Your best bet would be to browse their man page.
While these handy commands are convenient to have, you may want to checkout Atlassian’s ‘Source Tree’ plugin. It is convenient to those who are GUI oriented.
Please do not hesitate to reach out if you need help with branching and release strategy as well as training your team using Git. I am glad to help!
Three years have passed since I have transitioned to technology entrepreneurship journey with my partner -- in life and in business venture. While the Sitecast software has been built over the past 10 years, it is incredible what we have accomplished all these years.
List of books in product and personal development and futuristic stories, I would personally recommend.
Want to get updates from me? Please subscribe or connect with me.