You are on page 1of 2

Best Practices for Using Git

Why Git?

Git was designed to support various project and team setups by swiftly coordinating the
workflow on those projects. Git i is an open-source system which is used by a large
community.

Is the tool right for you and your team?

Here are some common scenarios where Git can apply:

• You are working on a large project.


• You need to collaborate with multiple people.
• You are a technology newbie.

Best practices for using Git

• Commit regularly
• Keep history consistent
• Always pull the latest updates
• Rebase your branches periodically
• Protect your project
• Choose the right developers for the job
• The more approvals, the better
• Make time tracking easier
Few commands which we use commonly

1. Clone. -> git clone <repo url>


2. Checkout -> git checkout master || git checkout -b dev origin/master
3. Pull. -> git pull || git pull <origin branch>
4. Status -> git status
5. Add -> git add . || git add <files>
6. Commit -> git commit -a
7. Commit —amend. -> git commit —-amend
8. Push. -> git push || git push <origin branch>
9. Merge -> git merge master
10. Branch -> git branch
11. Log -> git log
12. Whatchanged -> git whatchanged
13. Stash -> git stash
14. Delete Branch -> git branch -d <branchName> || git branch -D <branchName>
15. Reset Head. -> git reset --hard <commit id>
16. Rebase -> git checkout master -> git pull -> git checkout dev ->
git rebase master -> git mergetool -> git rebase —continue
git push -f

You might also like