NetEase Video Cloud is a cloud-based distributed multimedia processing cluster and professional audio and video technology designed by NetEase to provide stable, smooth, low-latency, high-concurrency video streaming, recording, storage, transcoding and VOD, such as the PAAs service, online education, telemedicine, entertainment show, Online finance and other industries and enterprise users only through simple development can create online audio and video platform. Now, NetEase video cloud Technical experts to share a technical article: remember once. Gitignore operation details.
"As a novice driver on the road, Git is certainly far away from the cool git GUI, because it's easy for you to ignore Git's own workflow and go to the abyss of Doom," he writes. &N Bsp , &NB Sp ----A veteran driver who had been on the road for years told me that this was the background of this, and in our project release system, Locally developed CSS files with scss real-time Watch compilation method, the final release to the online, will also be re-compression of the merged CSS files, has been no problem. But as the number of developers, the increase in the frequency of code submissions, as well as everyone's editor environment, will lead to the compilation of CSS files slightly different, such as someone watch out of the CSS file will have charset declaration: @charset "UTF-8"; Changes to these files have been submitted. This time when I go to pull the code, every time there will be a lot of conflict, I have to stop, change the scss file, watch again, in order to submit my changes. For a long time, the efficiency of the work is reduced. OK, there are problems to solve Bai, I consider that the Scss file will be compiled when the code is published in a CSS file, there will be a corresponding compression merge, and so on, the CSS file and CSS directory ignore not good? When developing, watch, release, rely on the Automation tool script to perform a series of watch update packaging operations, there is certainly no problem. So, I pro opened the. gitignore file, snapped, added css/ignore rule, commit commit. This time there is a CSS file modification, git status to see, hey, swollen css file or changes not staged for commit , I gitignore regular expression is wrong? Check some, it seems that no problem ah. Okay, Google a bit.: I misunderstood. How to use the. gitignore file, .gitignore can only be used for untracked files, which is a file that has not been recorded by Git, or that does not have add and commit related operations. This explains the fact that my rules don't work because the files in the CSS directory have a git operation record, and then add them to the. Gitignore is not available. To solve this problem, we can do this:
- Delete GIT's tracking information for this file;
# -r 递归删除文件夹里内容git rm -r --cached <path>
- Update. Gitignore, write the corresponding rules. Gitignore
- Add+commit + push.
Well, try, Commit,push code at this time if there is a CSS file modification, we git status test strange, this How to, the CSS file tracking also deleted, Gitignore also updated, also pushed to the remote branch, but not yet. Take a look. Gitignore found that the ignore of the CSS directory already exists in. Gitignore, and our update is not in effect. All right, first put the. Gitignore in the css/ignore rule delete, commit the code. Re-execute the above 1->2->3 step again to modify the CSS file, OK, done!
PS: About. Gitignore invalid there is another solution, but this scheme has sequela, not recommended. Is that I can set:
git update-index --assume-unchanged <PATH>
Let git ignore the files I need to exclude locally and commit to the remote branch so that Git doesn't commit the changes to the repository. So, what's the problem with this program? Setting Update-index this exclude is for files that are logged in the Git database, in other words. The Git/info/exclude directory is the file you need to exclude locally, not the files in the remote repository that really need to be ignored. Such a setting is not committed to the repository, nor does it affect others. In view of our. Gitignore the file itself is submitted to the repository.
The problem is that if you want to really ignore the submission of these files, everyone in the team must set up git update-index--assume-unchanged <PATH> to be effective. If a newcomer comes in or changes the computer at this time, the latest code from the vault is not executed, git update-index--assume-unchanged <path>, and Git begins to record the change in the file. So we don't recommend this approach. ----------------------------------------------------------------I'm a split line---------------------------------------------------- ---------solve the above problem, according to the old driver since the beginning of my education, as well as the requirements of our Technical group, summarize the use of git some of the artifice and good habits:
1. Review the changes carefully before you submit the code. Code submission is careful, you can use git status, Git diff before the operation, to see if there is a mistake to change the file, or there is no debugger, alert and other debugging code submission. According to experience, many times, the small hand shakes, submitted some inexplicable changes, this troubleshooting is time-consuming and laborious.
2.pull and push are best with the branch name. At the same time Push.default please change to simple mode. When we upgrade git, we'll look at the following tips:
warning:push.default is unset ; Its implicit value is changing in Git 2.0 from " Matching ' to . To squelch this messageand maintain the current behavior after the default changes, Use:git config--global push.defaul T matchingto squelch This message and adopt the new behavior now, use:git config--global push.default simple
As we can see, git 2.x defaults to simple, and Git 1.x defaults to matching, which means that Git 2.x handles the current branch by default without specifying a branch, and Git 1.x will push all your local branches to the corresponding branch in the remote repository. This is a very dangerous thing to do, especially if the master branch is having permission control exceptions. Our side has been the Master Branch permissions control problems, some colleagues to the master branch of the wrong operation submitted up, the consequences imaginable. As a precaution, modify the Push.default first, then pull and push with the remote branch name.
3. Configure Git alias to save a lot of git operation time
alias.st status
# git操作频次较高的命令大概有一下几个:[alias] st = status ci = commit co = checkout br = branch
4. About Git rebaseTo ensure that the GIT submission tree is clean and to avoid a dazzling merge operation, it is recommended that you replace it with Git rebase.
5. Optimize the commit log for git commitGit commit as far as possible not only simple update,dev,bugfix and so on, because these tags do not facilitate the subsequent problem location lookup. Our development team has been mandatory, who will submit such a simple commit mark, to please eat fruit, seems to have a lot of students recruit ~
In short, for the use of GIT tools, still need to slowly grope, constantly practice. When you use proficiency, and then with the Git GUI is no problem. Finally, I hope this article can be useful to everyone, you have any good git operation suggestions, welcome to Exchange ~
NetEase Video Cloud Technology share: remember once. Gitignore operation details