Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Mastering git - Workflow
1. Mastering Git
A Day with Git Workflow
Presented by-
Tahsin Abrar
Sr. Software Engineer
Blog: tahsinabrar.com
twitter: @TahsinAbrar
2. Git - What is it?
Git is a free and open source distributed version control system created by Linus
Torvalds in 2005 ( Who is also the creator of Linux kernel ).
It is designed to manage everything for small or very large projects with speed
and efficiency.
Majors organisations like Google, Facebook, Microsoft uses GIT daily.
3. But, It’s too complicated!
Most of the developer who doesn’t use git or
using git very little, they came up saying,
“Git is too complicated. It’s too hard to learn.
I don’t really understand it.”
Actually, Git is very easy to use and learn and
especially considering how powerful it is!
If you can have the basic understanding of git
flow, it’ll be a life saviour for YOU.
4. Typical Git Workflow
Pull the latest changes from remote
Write some codes
Add new files for staging
Commit the changes with readable commit message
Push the commit
Repeat.
5. Git Basic
git add file/path
To add all files: “ git add . ” OR “ git add -A ”
Commit: git commit -m “Your commit message”
View remote: git remote -v
To show the changes that you made after the last commit : git diff
To show all the previous commits in terminal : git log
Ref: http://tahsinabrar.github.io/2015/10/22/git-lifehacks/
6. Git Basic
To remove a file from git repo: “ git rm file/path ”
To move/rename a file: git mv current/file/path new/file/path”
To show all commits with reference log: git reflog
To show all the previous commits messages only in terminal: git log --oneline
Enhance the previous command: git log --oneline --graph
To show only few of the previous commits in terminal:
git log -<number>
i.e. git log -2 for last two commits
7. Git Clean/reset
To clean the current working directory from the last commit:
git clean -f
Remember, it’ll permanently remove your current changes.
You added the file to the stage, but not commited yet, Then:
git reset HEAD file/path
To reset the last commit that you didn’t push:
git reset --soft HEAD~1
To remove the changes of a file: git checkout file/path
8. Git Stash - THE Rescue
You’re in the middle of some changes but something comes up that you need to jump over
to, like a so-urgent-right-now bugfix, but don’t want to commit or lose your current edits. git
stash is there for you.
Run: git stash to make the working repository clean. And It will then leave you at the state
of the last commit.
Run: git stash pop or git stash apply to bring back the stashed code into the working
directory.
Run: git stash list to show the lists of stash items.
9. Git Branching
Create a new branch :
git branch newBranchName
Checkout to newly created branch:
git checkout newBranchName
Or, you can combine these two command with:
git checkout -b newBranchName
Delete a branch:
git branch -d branchName
Delete a branch forcefully:
git branch -D branchName
10. What should be gitignored ?
If you’re using composer, then of course you should ignore /vendor directory.
If you’re using bower, then you should also ignore :
/bower_components directory.
If you’re using npm, then ignore: /node_modules directory
If you’re using sass as CSS Pre-processor, then ignore: /.sass-cache
directory
And always ignore upload files path
11. Merge conflicts!
the number of planets are
<<<<<<< HEAD
nine // ---- This is your changes
=======
eight // ---- This is your friend’s changes
>>>>>>> myBranch
In myBranch, you wrote the word "nine," but your friend
wrote "eight." Git automatically adds conflict markers to
the affected areas. A conflict-marked area begins with
<<<<<<< and ends with >>>>>>>. These are also
known as the conflict markers. The two conflicting
blocks themselves are divided by a =======.
12. Using Git flow
It’s a great tool that will help if you’re working with a big team.
Ref: http://danielkummer.github.io/git-flow-cheatsheet/
13. Q & A
Thanks for your time.
Ask your valuable questions!