Using GitHub with Cygwin After Setting Up an RSA Key and a User
Posted on June 17, 2014 in Command Line, GitHub, Linux by Matt Jennings
Open Cygwin and navigate to the parent directory or where your repositories are located.
- If needed type
chgrp Users *and pressEnterto ensure that all of the repositories in that parent directory are added to a user group. - Change the permission for your repository to 700 like the example below:
chmod 700 myGitHubRepository
- To ensure that the permission of your
myGitHubRepositorydirectory was changed to 700, typels -aland pressEnterto see a list of all directories, including additional information like their permissions and group memberships. - Then you should see something like below on the line that contains information for your myGitHubRepository.The
drwx------text refers to a permission of 700 where only theyourUserNameuser can read, write and execute the files in themyGitHubRepositorydirectory. See this article on Unix and Linux permissions by William E. Shotts, Jr. for more details.drwx------+ 1 yourUserName Users 0 Jun 17 14:46 myGitHubRepository
- Type
git push -u origin masterand press Enter to ensure that you will be able to push the master branch of themyGitHubRepositoryto your GitHub account. You will need to enter your GitHub username and password. If everything works correctly you should see a confirmation message like below:Everything up-to-date
- Now you will only need to type
git push, pressEnterand type your GitHub username and password and yourmyGitHubRepositorymaster branch will be pushed to your remote GitHub account. - To create a new branch called
codeTesttypegit branch codeTestand pressEnter. - To edit code in the new
codeTestbranch typegit checkout codeTestand pressEnter. - To confirm that you are now in the
codeTestbranch typegit branchand pressEnter. You will now see text like below:master * codeTest
- To commit the
codeTestbranch type the code below and pressEnter. The “code test” text in the double-quotes is a comment that will eventually be submitted along with thecodeTestbranch to your remote GitHub account.git commit -a -m "code test"
- Type
git pushand press Enter to ensure that thiscodeTestbranch is pushed to your remote GitHub account. You’ll see a success message that says something like:Everything up-to-date
- To see your current Git status type
git statusand pressEnter. Some of your output text may sayOn branch codeTest. - While still in the
codeTestbranch, edit a file. Then to get that file ready to push to your remote GitHub account typegit checkoutand pressEnter. If you edited anindex.htmlfile you’ll see something like the output text below:M index.html
- To commit the modified
index.htmlfile of yourcodeTestbranch to your yourmyGitHubRepository, typegit commit -a -m "another update"(once again the"another update"text is a comment that will be pushed with the modified branch) and pressEnter. - To push the modified
index.htmlfile of yourcodeTestbranch to your yourmyGitHubRepositoryon your remote GitHub account, typegit pushand pressEnter. - To ensure you don’t need to enter passwords every time you do a push, make sure you are in the the your
myGitHubRepositorydirectory and typecd .gitand pressEnter. Then if you have Gnu nano (command line text editor) installed typenano configto edit this file in your shell. - Per this blog post from Sneek Digital, replace the text similar to
url = https:///GitHubUserName/myGitHubRepository.gitwith the new text below:url = :GitHubUserName/myGitHubRepository.git - After making the changes to the config file, press
Ctrl + x, then typeyesand pressEnterand finally pressEnterto fully save the file and exit it. - Navigate back to your
myGitHubRepositorydirectory. Typessh-addand pressEnter. Then you’ll seeEnter your passphrase for[more characters here]rsa:text output. Type your RSA key password and pressEnter. - To ensure that you don’t need to enter your password every time you push a branch to your remote GitHub account, type
git pushand pressEnter. Hopefully you won’t need to enter a password. - Finally, to switch back to the
masterbranch typegit checkout masterand pressEnter. Then when you type git branch and press Enter you see something like this output:* master codeTest