newdevs:git:create
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
newdevs:git:create [2019/06/28 17:06] – created tmccanna | newdevs:git:create [2024/03/12 15:10] (current) – tmccanna | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | **New Developers Working Group** | ||
====== Git for Windows ====== | ====== Git for Windows ====== | ||
- | ===== Using Git to Create | + | ===== Using Git to Create |
+ | When you make code changes that you wish to post for review, you will create a git branch to store them in. | ||
==== 1. Update Your Local Repository ==== | ==== 1. Update Your Local Repository ==== | ||
Line 8: | Line 10: | ||
- Open Git Bash | - Open Git Bash | ||
- Navigate into your Evergreen repository | - Navigate into your Evergreen repository | ||
- | - If the master | + | - If the main branch isn't currently checked out, check it out: git checkout |
- Before making any changes, make sure your local files are up to date with latest changes: | - Before making any changes, make sure your local files are up to date with latest changes: | ||
<code bash> | <code bash> | ||
- | git pull origin | + | git pull origin |
</ | </ | ||
+ | |||
+ | Note: Depending on how Git is configured on your machine, you may just be able to enter: git pull | ||
+ | |||
==== 2. Create a New Branch to Store Your Changes ==== | ==== 2. Create a New Branch to Store Your Changes ==== | ||
- | Create and checkout a branch to store your changes. | + | Create and checkout a branch to store your changes. |
<code bash> | <code bash> | ||
- | git checkout -b user/username/ | + | git checkout -b lp123456_launchpad_bug_description |
+ | </code> | ||
+ | |||
+ | Note: In most cases you will want to create a branch based off of main. You can do this either by a) specifying main on the command line: | ||
+ | |||
+ | <code bash> | ||
+ | git checkout -b lp123456_launchpad_bug_description main | ||
+ | </code> | ||
+ | |||
+ | Or, b) you can switch to main first and then create the new branch. This also gives you the opportunity to make sure your local copy of main is updated first: | ||
+ | |||
+ | <code bash> | ||
+ | git checkout main | ||
+ | git pull origin main | ||
+ | git checkout -b lp123456_launchpad_bug_description | ||
</ | </ | ||
==== 3. Make Your Changes ==== | ==== 3. Make Your Changes ==== | ||
+ | |||
- Edit the file(s) you wish to change. You can either do this by launching a text editor from within Git Bash (notepad++ filename.tt2) or you can do so by opening and editing the file from Windows Explorer. | - Edit the file(s) you wish to change. You can either do this by launching a text editor from within Git Bash (notepad++ filename.tt2) or you can do so by opening and editing the file from Windows Explorer. | ||
- Verify that Git recognizes the files you have modified: git status | - Verify that Git recognizes the files you have modified: git status | ||
- Add the file(s) you have changed to the staging area: | - Add the file(s) you have changed to the staging area: | ||
- | * To stage a specific file, use: git add myfilename.txt | + | * To stage a specific file, use: **git add myfilename.txt** |
* To stage //all// changed files, use: git add -A | * To stage //all// changed files, use: git add -A | ||
* If you accidentally stage a file you didn't mean to, you can unstage it: git reset HEAD myfilename.txt | * If you accidentally stage a file you didn't mean to, you can unstage it: git reset HEAD myfilename.txt | ||
- | - Commit the staged changes: git commit | + | |
- | - When your text editor opens to write the commit message, the first line should be the launchpad number and name, followed by the description, | + | * https:// |
+ | | ||
+ | * Note: The -s portion adds the sign-off line for you. | ||
+ | - When your text editor opens to write the commit message, the first line should be the launchpad number and name, followed by the description | ||
LP#1406387 Fix for Holds Placement Advanced Options | LP#1406387 Fix for Holds Placement Advanced Options | ||
Line 38: | Line 61: | ||
empty, regardless of whether the radio input for the | empty, regardless of whether the radio input for the | ||
hold was specified for a patron or the staff member. | hold was specified for a patron or the staff member. | ||
+ | | ||
+ | To reproduce the problem: | ||
+ | [1] Open a patron' | ||
+ | [2] On the hold placement screen, click Advanced Hold options. | ||
+ | [3] You will see that the staff barcode is filled in rather than the patron. | ||
+ | | ||
+ | To test the fix: | ||
+ | [1] Open a patron' | ||
+ | [2] On the hold placement screen, click Advanced Hold options. | ||
+ | [3] Verify that the patron barcode is filled in. | ||
+ | [4] Test placing a hold directly from the catalog and confirm that the | ||
+ | staff or patron barcode is carried over from the main hold page. | ||
+ | | ||
+ | Release-note: | ||
| | ||
Signed-off-by: | Signed-off-by: | ||
- | |||
- | |||
==== 4. Push Your Changes to the Evergreen Working Repo ==== | ==== 4. Push Your Changes to the Evergreen Working Repo ==== | ||
- | Upload | + | In order to share your branch, you will need to upload |
<code bash> | <code bash> | ||
- | git push working user/username/ | + | git push working |
</ | </ | ||
Line 60: | Line 95: | ||
- In the related launchpad bug, add a comment that your patch is ready for review, along with the URL you copied. | - In the related launchpad bug, add a comment that your patch is ready for review, along with the URL you copied. | ||
- Add a " | - Add a " | ||
- | |||
- | ===== Using Git to Test Patches ===== | ||
- | |||
- | ==== 1. Update Your Local Repository ==== | ||
- | |||
- | - Open Git Bash | ||
- | - Navigate into your Evergreen repository | ||
- | - If the master branch isn't currently checked out, check it out: git checkout master | ||
- | - Make sure your local repository is current: git pull origin master | ||
- | |||
- | ==== 2. Identify the Commit ID for the Patch ==== | ||
- | |||
- | Identify the unique commit identifier for the patch you wish to test. This is found by clicking on a link in the related launchpad bug, or navigating to [[https:// | ||
- | |||
- | {{ : | ||
- | |||
- | ==== 3. Create a Local Testing Branch ==== | ||
- | |||
- | - Create and checkout a local testing branch: git checkout -b lp12345 | ||
- | - Pull changes into the testing branch using the unique commit id: git cherry-pick 7ab7281f5 | ||
- | - Test the changes on your test server. | ||
- | |||
- | **//NEED MORE INFO | ||
- | * If you have direct Git Bash access to your test server... Need Additional Information - how do changes get compiled? Through a git merge ? | ||
- | * If you do not have Git Bash access to your test server, but you have file system access to your test server through WinSCP or a similar FTP-style program, manually copy the changed files to your server for testing. | ||
- | //** | ||
- | |||
- | ==== 4. Create a Sign-Off Branch ==== | ||
- | |||
- | If testing is //not// successful, update the launchpad bug report with details. | ||
- | |||
- | If testing //is// successful, acknowledge it by adding a sign-off branch: | ||
- | |||
- | //** NEED BETTER INSTRUCTIONS HERE - I still don't quite understand how to create a branch that only contains a sign-off - does it contain all the changed files AND the sign-off? Or just the sign-off? **// | ||
- | |||
- | <code bash> | ||
- | git push working lp12345: | ||
- | </ | ||
- | |||
- | |||
- | ==== 5. Update Launchpad ==== | ||
- | |||
- | - In the relevant launchpad but, add the " | ||
- | - Also, add a link in the comments to your sign-off branch. | ||
- | |||
- | ===== Useful Git Bash Commands ===== | ||
- | |||
- | **Git Commands** | ||
- | * git add myfile.txt --> stage a specific file | ||
- | * git add -A --> stage all modified files in the current directory and subdirectories | ||
- | * git add . --> (Note the period) stage all modified files in the current directory but not subdirectories | ||
- | * git branch --> list existing local branches | ||
- | * git branch mynewbranch --> create a new branch | ||
- | * git branch -m oldbranchname newbranchname --> change name of branch | ||
- | * git branch -D branchname --> delete a local branch (cannot delete a branch you currently have checked out, so switch to different branch first) | ||
- | * git checkout mybranch --> check out an existing branch | ||
- | * git checkout -b mynewbranch --> create a new branch and check it out at the same time | ||
- | * git checkout master --> switch to master branch | ||
- | * git checkout -- docname.tt2 --> resets a file you've changed back to its original state (like an undo / revert changes command) | ||
- | * git clone < | ||
- | * git commit --> invoke the default text editor to add a commit message | ||
- | * git commit -m "my commit message" | ||
- | * git commit < | ||
- | * git commit < | ||
- | * git commit -a --> combine the git add and git commit steps into a single step (does //not// include newly created files) | ||
- | * git config < | ||
- | * git config < | ||
- | * git fetch < | ||
- | * git help --> access the built-in Git help documentation. | ||
- | * git log < | ||
- | * git pull --> imports all updates from your default remote repo to your default local repo (usually, this is equivalent to 'git pull origin master' | ||
- | * git pull origin master --> import all updates from remote origin repo to local master repo | ||
- | * git pull < | ||
- | * git push working mybranchname --> push changes to the remote working directory | ||
- | * git push working < | ||
- | * git remote -v --> display remote directories | ||
- | * git reset HEAD myfile.txt --> unstage a file that has already been staged | ||
- | * git reset < | ||
- | * git rm badfile.txt --> delete a file (if the file is being tracked, be sure to add a commit message indicating the file has been deleted) | ||
- | * git show < | ||
- | * git status --> display status of current branch | ||
- | * git version --> displays the installed version of Git | ||
- | |||
- | **Other Commands** | ||
- | * cd --> move back to the home folder | ||
- | * cd foldername --> move from the current folder to a child folder | ||
- | * cd .. --> move up in the folder hierarchy one level | ||
- | * clear --> clears your command window giving you a fresh screen to work with | ||
- | * ls --> list all of the folders and files in the current folder | ||
- | * mkdir newfoldername --> create a new folder | ||
- | * notepad++ newdocname.txt --> create a new file and open it in notepad++ | ||
- | * notepad++ docname.txt --> edit an existing file in notepad++ | ||
- | * pwd --> see what folder you are currently in | ||
- | |||
newdevs/git/create.1561755973.txt.gz · Last modified: 2022/02/10 13:34 (external edit)