Git is overly complicated!
Git used to be a bit... mmm overly complicated ball of fur, back in the days, but those days are long gone. Here's what Mr. Torvalds thinks about that:Interviewer: People have said that Git is only for super smart people. Even Andrew Morton said Git is "expressly designed to make you feel less intelligent than you thought you were." What's your response to this?10 Years of Git: An Interview with Git Creator Linus Torvalds, 26th May, 2015
Torvalds: So I think it used to be true but isn't any more. There is a few reasons people feel that way, but I think only one of them remains. The one that remains is fairly simple: "you can do things so many ways."
Git is awesome, honestly
Nowadays git works really well even for non-super-nerd-kind-of-software-developers. So, basically I really recommend in starting to use that, even though you'd have background in other SVNs. Git doesn't really have any childish problems, it doesn't rely on your internet connection and it really gives you some nice tools for improving your team and your code quality.
However if you're using git as you'd using SVN you really should consider to use Feature Branch Workflow instead. Since when using the git as SVN it won't really justify the existence of the software.
If you're using Git without branches, please reconsider
If you're just developing your application by using the master branch, you really should try feature branch workflow. It gives you a number of benefits over the basic workflow.
So what are exactly the benefits?
So what are exactly the benefits?
- All features are encapsulated.
- Pull requests -> bump up your team's communication, learning and quality.
- Pull request, yes again. If you get stuck with your code, asking help is really easy. Just make a new PR and yell for help.
- Master branch will (hopefully) never break.
Here are some solid basic settings for your git (in Ubuntu)
1. Install git bash autocompletion
Autocompletion is a breeze, you'll love to find your branches and git features when you keep banging your tabulator.
Autocompletion is a breeze, you'll love to find your branches and git features when you keep banging your tabulator.
sudo apt-get install git bash-completion
2. Add to your ~/.gitconfig
Everyone loves colors!
Everyone loves colors!
[color]branch = autodiff = autostatus = auto[color "branch"]current = yellow reverselocal = yellowremote = green[color "diff"]meta = yellow boldfrag = magenta boldold = red boldnew = green bold[color "status"]added = yellowchanged = greenuntracked = cyan
3. Add your personal settings
Add your username, email, default editor, simple push, and timeout for your credentials.
Add your username, email, default editor, simple push, and timeout for your credentials.
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
git config --global core.editor vim #All cool guys loves vim!
git config --global push.default simple #make sure that you're only pushing the active branch
git config --global credential.helper 'cache --timeout=27000' # remember credentials for 7.5h
Pretty good basic workflow for anyone
Get the copy of the repository, only needed on 1st run:
git clone https://your-repo # make a local copy of the repository
Start working with a new branch:
git checkout -b name_of_the_feature master #-b creates a new branch if it's not existing
Make some work and commit your results to local repository. Lather, rinse and repeat:
git add <file_name>
git commit # Check out
how to write good commit messages
Keep the copy of your branch in central repository only needed on 1st run:
git push -u origin name_of_the_feature #push the feature branch to the central repo.
Finish your work:
git rebase -i <first-commit-hash-of-the-branch> #Squash commits in to logical sections
git checkout master; git pull; git <feature_branch> #update the master
git rebase master #if someone has merged some new branches in to master.
git push
Where does the learning take place?
The learning and static QA-process starts now! When the feature is finished and new branch is about ready to be merged in to the master. The name of this phase is pull request.
Pull request
Pull request really give you a great set of tools for code review, learning from the code and collaboration around the specific feature branch.
Ei kommentteja:
Lähetä kommentti