Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Most used git commands
- =======================
- git init [project name] # From scratch -- Create a new local repository
- git status #List new or modified files not yet commited
- git log # Show full change history
- git add . # Stage all changed files ready for commit
- git commit -m "added Day-1 projects" # Commit all staged files to versioned history
- git remote add origin remote repository URL #Sets the new remote
- git remote -v # Verifies the new remote URL
- git push origin main # Push local changes to the origin
- Working with branches
- =======================
- git branch # list all local branches
- git cranch -av # list all branches , local and remote
- git checkout my_branch # switch to a branch, my_branch and update working directory
- git branch new_branch #create a new branch called new_branch
- git branch -d my_branch # delete the branch called my_branch
- #merge branch_a into branch_b
- git checkout branch_b
- git merge branch_a
- #Merge vs Rebase
- git merge test
- git rebase test
- Synchronize
- ============
- git fetch #Get the latest changes from origin (no merge)
- git pull #Fetch the latest changes from origin and merge
- git pull --rebase # fetch the latest changes from origin and rebase
- Rolling Back
- ==============
- git log # Check our previous commits and their hashes
- git revert Hash # Rollback to previous commit
- git checkout Hash # Check out previous commits # git checkout master #to switch back to the branch you werer working in
Advertisement
Add Comment
Please, Sign In to add comment