Table of Contents
Pushing to existing repo from other folder
- Commit messages ‣
- Git Branch naming ‣
Basic commands
- GitHub platform for storing , tracking and collaboration ( cloud)
git show SHA
shows all about that commit
git log --oneline
shows all the commit logs in on line with short id namegit log -n “number”
gives that many number of commits
git reset filename
removes from the staging area
git blame
shows the history of everything about a file
git commit —ammend -m “XYZ”
- edit the previous commit
HEAD
is the latest commit thingy
- Reverting is nothing but putting the
HEAD
at a certain commit
- if we do like this then we loose the history like we can go to a particular commit and loose the history
git reset --hard sha
- IF we do reverting then we have a new commit and all the history too
git revert id
stash
your local changes before pulling to your local machine
Branching
- default branch is main aka (master)
git log --oneline --graph --all
- shows graph of branches and merging thingy.
- creating
git branch 'xyz' 'or' git checkout -b "abc" "OR" git switch -c "XYZ" Creates a new branch and switches to it automatically
- viewing all branches
git branch
- Moving to desired branch
git checkout "xyz"
- pushing
git push --set-upstream "xyz"
- PR
- Method 1
git checkout main git merge origin/xyz git push
- make a pr in github
to
→from
- Merge it
- checkout main in CLI
- pull
- Naming conventions of branches
wip Works in progress; stuff I know won't be finished soon feat Feature I'm adding or expanding bug Bug fix or experiment junk Throwaway branch created to experiment
Rebase vs merging
- history is maintained in rebse
- pollutes commit history