You can basically google everything for git you want, but I’m going to share some of the commands I use most of my daily job.
- Get start with the project
git clone: git repo url
2. Create you own branch, so you won’t mess up the master
git checkout -b name(<--- you branch name)
what you hate the branch name you create on your local? Sure delete it
git branch -d name
3. Now you add some file or change some thing, want to create PR tell you team I’m working actually.
git commit -m
(This can add multiple line for your commit, usually will open a little text editor in the command line)
- hit i (mean insert)
- Start typing your awesome change
- hit ESC
- Cursor will be very button of the line, then type below
- :wp (means write and quick)
Other short message will be
git commit "your message"
4. Push to the git space
git push (woohoo!)
If the branch is brand new, git will till you to do:
git bush orgin xxxxx (It's show up in the command line)
5. Your branch is updated and have conflict with master? It’s okay! things happen.
git checkout dev
git pull
git checkout your branch
git merge dev
(VS code will list the file have conflict)
- Fix the conflict
- Add to the change to stage
- git commit -m
- git push (Happy!)
6. OH! Wait! I mess up, need to go back to previous commit
git log (see which commit you need to go back to, and choose the commit number before)
git reset --soft xxxx(commit number)
I will add it more if I remember anything else but hope this helps my limited memory of brain space in the future.
Ps: Great talk from a Github guy use git, now that credibility 🙂