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 pressEnter
to 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
myGitHubRepository
directory was changed to 700, typels -al
and pressEnter
to 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 theyourUserName
user can read, write and execute the files in themyGitHubRepository
directory. 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 master
and press Enter to ensure that you will be able to push the master branch of themyGitHubRepository
to 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
, pressEnter
and type your GitHub username and password and yourmyGitHubRepository
master branch will be pushed to your remote GitHub account. - To create a new branch called
codeTest
typegit branch codeTest
and pressEnter
. - To edit code in the new
codeTest
branch typegit checkout codeTest
and pressEnter
. - To confirm that you are now in the
codeTest
branch typegit branch
and pressEnter
. You will now see text like below:master * codeTest
- To commit the
codeTest
branch type the code below and pressEnter
. The “code test” text in the double-quotes is a comment that will eventually be submitted along with thecodeTest
branch to your remote GitHub account.git commit -a -m "code test"
- Type
git push
and press Enter to ensure that thiscodeTest
branch 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 status
and pressEnter
. Some of your output text may sayOn branch codeTest.
- While still in the
codeTest
branch, edit a file. Then to get that file ready to push to your remote GitHub account typegit checkout
and pressEnter
. If you edited anindex.html
file you’ll see something like the output text below:M index.html
- To commit the modified
index.html
file of yourcodeTest
branch 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.html
file of yourcodeTest
branch to your yourmyGitHubRepository
on your remote GitHub account, typegit push
and pressEnter
. - To ensure you don’t need to enter passwords every time you do a push, make sure you are in the the your
myGitHubRepository
directory and typecd .git
and pressEnter
. Then if you have Gnu nano (command line text editor) installed typenano config
to edit this file in your shell. - Per this blog post from Sneek Digital, replace the text similar to
url = https://
with the new text below: /GitHubUserName/myGitHubRepository.giturl =
:GitHubUserName/myGitHubRepository.git - After making the changes to the config file, press
Ctrl + x
, then typeyes
and pressEnter
and finally pressEnter
to fully save the file and exit it. - Navigate back to your
myGitHubRepository
directory. Typessh-add
and 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 push
and pressEnter
. Hopefully you won’t need to enter a password. - Finally, to switch back to the
master
branch typegit checkout master
and pressEnter
. Then when you type git branch and press Enter you see something like this output:* master codeTest