[Git] Working Together

LINE ENDINGS I

Your company just hired a new developer who works on a Windows computer, and you notice that some files seem to be missing line separators. You realize that the Windows machine is saving files with a different line separator character than the Unix stations. Here on your Unix machine, set your 'git config' variable to convert line endings to the Unix way on commit.

git config --global core.autocrlf input

 

 

LINE ENDINGS II

Because you're a nice person, you decide to go help the new developer convert line endings to work on his windows computer. Set the git config variable to convert line endings from Unix to Windows formats on checkout.

git config --global core.autocrlf true

 

LINE ENDINGS III

After helping a 3rd Windows developer set up their workstation, you've decided enough is enough. It's time to add a .gitattributes file to handle all these line ending problems. Finish adding the options to the *.bat and *.sh files. Remember, *.bat is a windows file, while *.sh is a unix file.

*     text=auto
*.rb text
*.js text

*.bat text eol=crlf
*.sh text eol=lf

*.png binary

 

 

CHERRY PICKING

You were working on a new feature for the Unicorn class, when you happened to find a fix for a bug that was causing Unicorns to stop sparkling on occasion. You really want this commit in master ASAP. Cherry-pick the commit with a sha of 3fbd473 to the master branch.

git cherry-pick 3fbd473

 

EDIT A CHERRY PICK

You've realized that this commit 3fbd473, which you need to cherry pick, has a rather vague message. Do another cherry-pick, but edit the commit message this time.

git cherry-pick --edit 3fbd473

 

CHERRY PICK SQUASH I

You've fixed another bug that was causing the unicorn horn to be blunt instead of nice and sharp, but you had to make an extra commit to remove some debugging code. We want to convert these two commits to a single commit on the master branch. Cherry-pick commits"b447335" and "b59d285", without committing them to the current branch.

git cherry-pick --no-commit b447335 b59d285

 

CHERRY PICK SQUASH II

The changes from both cherry picked commits are now on master, and all that's left to do is to commit these changes. (Don't forget the commit message!).

git commit -m "squash"

 

TRACKING CHERRY PICKS

There has been a lot of cherry picking lately, so the decision has been made to keep track of where these commits are coming from. Cherry pick the "bug fix" commit with a sha of"bdf9578". Use the option which keeps a record of where the commit was cherry picked.

git cherry-pick -x bdf9578
 

[master 0dcfa72] Bug fix. (cherry picked from commit bdf95785e56f401642373bdce471d33cdfd52ff0)
 1 file changed, 4 insertions(+)

 

SIGNING OFF

You've decided that it is probably a good idea to put your name on these commits you're cherry picking. Go ahead and get started by cherry picking the commit with a sha of "bdf9578". Don't forget to use the option which will sign off on the cherry pick!

git cherry-pick --signoff bdf9578
 

[master c77a126] Bug fix.
 1 file changed, 4 insertions(+)

posted @   Zhentiw  阅读(463)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示