官术网_书友最值得收藏!

Git

A lot of people reading this will use Git already. There’s a reason for that—it makes life simpler. Having a Git repository for all of your Lambda functions is a great way to work with teams of developers or by yourself on multiple machines.

Installing Git on your system varies depending on your operating system. Linux users can install Git through the command line, macOS users can install using Homebrew or via download, and Windows users have to install Git via download. Details on exactly how to install for your system are available on git-scm.com.

Once you have Git installed, navigate in the terminal to your Lambda folder. When inside that folder, run git init to create an empty repository. When you open your Lambda folder in VS Code, you will now have a number hovering over the Git symbol. This means that you have edited that number of files since your last Git commit.

Committing to Git is like taking a snapshot of all of the work in the folder and saving it. This is useful as it allows you to see how your work changes over time. To commit your work (take the snapshot) you have two options.

You can use the Git integration with VS Code to create the commit. Click on the Git symbol with the number hovering over it. When you click on that, it opens the changes menu, showing you all of the files that you have changed since your last commit, or all of your files if this is your first commit. To commit the changed work, type a message into the message box at the top and click the tick above that:

Git commit using VS Code integration

If you want to use the command line you need to enter git add * to add all of your changed files to the commit you're about to do. Then type git commit -m "My first git commit!". The text between the quote marks is your commit message.

In both cases, your commit message should describe the changes that you've made in this commit. Your first commit will probably be "creating my first function".

Another massive advantage to Git is that you can easily create remote Git repositories. These are data centers that will store your Git commits so you can access them from anywhere in the world. The major two are GitHub and Bitbucket but there are lots more. They both have free versions, but GitHub is only free for public repositories so anyone can see your work.

Once you've signed up for an account and created a repository, you'll be given a URL for it. In your terminal, navigate to your folder and run git add remote origin <your url>. This means that you can send work from your local machine to your online repository. Just type git push origin master to send your latest commits to your online repository. Getting them back is just as simple; just type git pull origin master and your local code will update to add in any changes made in your repository.

This is great for teams as it allows you to all work on your own machines but be able to get each other's changes.

主站蜘蛛池模板: 抚顺市| 廊坊市| 昆山市| 乌恰县| 藁城市| 凉城县| 广汉市| 台前县| 股票| 靖安县| 临汾市| 桃源县| 阿克陶县| 英山县| 和田市| 常山县| 葫芦岛市| 宁城县| 扶绥县| 行唐县| 嘉兴市| 章丘市| 三台县| 阿克陶县| 左权县| 南澳县| 龙胜| 禹城市| 卓资县| 临猗县| 金秀| 农安县| 镇安县| 朔州市| 新民市| 永济市| 尼勒克县| 乐业县| 社旗县| 江山市| 馆陶县|