How to Set Up and Use Git

Part 1 of 3:

Setting Up Your Account

  1. How to Set Up and Use Git Picture 1
    Set up a Github Account. Visit GitHub and create an account. For the purposes of this tutorial a free account will work just fine.
  2. How to Set Up and Use Git Picture 2
    Install Git Bash. In order to get started you must first download and install Git Bash for windows. Go ahead and do that now by following this link: Git Bash.
    1. Once it's installed, run Git Bash. You should be looking at a black command prompt screen. Git Bash uses Unix commands to operate so some knowledge of Unix is important to have.
  3. How to Set Up and Use Git Picture 3
    Create an SSH Key. In order to establish a secure encrypted connection between your GitHub account and Git Bash on your computer, you must generate and link an SSH key. In Git Bash, paste this code but substitute in the email you used with your GitHub account: ssh-keygen -t rsa -b 4096 -C "your_email@example.com'
    1. You will then be prompted as to where you want to save the key. The default location will suffice so just hit Enter. Next, Git Bash will ask you to enter and confirm a passphrase. While you don't have to include one, it's highly recommended that you do.
  4. How to Set Up and Use Git Picture 4
    Add your SSH key to the ssh-agent. This will authorize your computer to use that SSH key. Enter the following command to start the SSH Agent: eval "$(ssh-agent -s)" Then enter in ssh-add ~/.ssh/id_rsa to add your created key.
    1. If your key has a different name besides id_rsa or you saved it in a different location, make sure you use that instead.
  5. How to Set Up and Use Git Picture 5
    Add your SSH key to your account. You will now need to configure your account to use your newly created key. Copy the ssh key to your clipboard: clip < ~/.ssh/id_rsa.pub. Then, in the top right corner of any GitHub page, click on your profile photo, and then click Settings. In the user settings sidebar, click SSH and GPG keys. Then click New SSH Key. Now you can enter in a descriptive name for your key then paste your key into the key field, and press "Add SSH Key". Confirm it, and you're all set!
Part 2 of 3:

Setting Up a Project

  1. How to Set Up and Use Git Picture 6
    Fork a repository. In order to make changes to a project in GitHub, it must be forked. Go to the repository you want to work on, and fork the repository by pressing fork in the top right part of the page. This will make a copy of that repository on your account.
  2. How to Set Up and Use Git Picture 7
    Create a local directory. Create a folder somewhere on your computer where you want to house the repository. Then use Git Bash to navigate to that folder. Remember Git Bash accepts UNIX commands, so in order to get into your directory, use the CD command like so: $ cd /path/to/directory
  3. How to Set Up and Use Git Picture 8
    Clone the fork. In GitHub, navigate to your fork and under the repository name, click Clone or download, and copy the link it gives you.
    1. Next, in Git Bash, enter in the following command using your copied URL: $ git clone https://github.com/YOUR-USERNAME/REPOSITORY_NAME. Press Enter, and your local clone will be created.
  4. How to Set Up and Use Git Picture 9
    Sync your fork with the original. You need to be able to propose changes to the original repository. Navigate to the original repository that you forked in GitHub, then hit Clone or download and copy the URL.
    1. Now navigate into the actual repository folder in GitHub. You'll know you're in the right spot when you see a (master) to the right of your command prompt.
    2. Now simply run $ git remote add upstream https://github.com/user/repositoryName using the original URL of the repository.
  5. How to Set Up and Use Git Picture 10
    Create a user. Next you should create a user to track who made the changes to the repository. Run the following two commands. $ git config user.email 'you@example.com' and $ git config user.name 'Your Name'. Make sure the email you use is the same one that's on your git hub account.
  6. How to Set Up and Use Git Picture 11
    Create a new branch. Next you should create a new branch off of our master branch. As an actual branch of a tree. This branch will hold all of the specific changes you will make. You should create a new branch off of the master every time you work on a new problem. Whether it's a bug fix or the addition of a new feature, each task must get its own unique branch.
    1. In order to make a branch, simply run: $ git branch feature_x. Replace feature_x with a descriptive name of your feature.
    2. Once you've made your branch use $ git checkout feature_x. This will switch you into the feature_x branch. You are now free to make changes to your code.
Part 3 of 3:

Pushing Your Changes

  1. How to Set Up and Use Git Picture 12
    Commit your changes. Once you've finished making changes, or you want to switch branches and work on something else, your changes must be committed. Run $ git commit --all. This is will automatically commit all the changes you've made to the repository.
    1. You will get a prompt to enter in a commit message using vim. This message should be short and descriptive. Use the arrow keys to navigate to the top line, and then hit i on your keyboard. You may now type your message. Once it's typed, hit Esc and then hit the colon key, :. Now type in the letters wq and hit Enter. This will save your commit message and quit the vim editor.
  2. How to Set Up and Use Git Picture 13
    Make a push request. Now that your changes have been committed, you should push them! Enter in $ git push origin .
  3. How to Set Up and Use Git Picture 14
    Merge with the master branch. Go back to GitHub and you should soon see a message pop up with your push. Hit "Compare & pull request". On this page you will have the opportunity to review your changes, as well as change your commit message and add comments. Once everything looks in order, and GitHub doesn't detect any conflicts, go ahead and make the request. And that's it!
    1. Now it will be up to your other contributors and the owner of the repository to review your change and then merge it with the master repository.
  4. How to Set Up and Use Git Picture 15
    Always remember to fetch and rebase. It's extremely important to always be working on the latest version of a file. Before you make any push requests, or you've just started a new branch or switched to a branch, always run the following command git fetch upstream && git rebase upstream/master.
4 ★ | 1 Vote

May be interested

  • Check out the 'buffalo' Pokémon in Pokémon GoCheck out the 'buffalo' Pokémon in Pokémon Go
    each type of pokemon has hp, cp, ability to attack and endure differently. based on these indicators, players can determine as well as choosing the most powerful pokemon for their offensive tactics.
  • Sitting home can also locate Pokemon around, do you believe it?Sitting home can also locate Pokemon around, do you believe it?
    the tightening of the niantic developers' rules to prevent players from abusing the support tools also brings annoyance, such as those who have no conditions to move much, go away, it is hard to know. get the location of the pokemon around the area they live in
  • 5 undeniable benefits when playing Pokemon Go5 undeniable benefits when playing Pokemon Go
    get to know many new people, breathe fresh air, relieve stress, increase concentration thanks to going out for a walk .... are compelling reasons to force you to try pokemon go now .
  • Want to earn the fastest Pokécoins in Pokémon Go? So don't miss this article!Want to earn the fastest Pokécoins in Pokémon Go?  So don't miss this article!
    pokécoins in pokémon go play the role of buying items in the store. the more coins you earn, the more likely you are to buy more items. to earn pokécoins, players will have to complete certain tasks or buy real money.
  • Pokémon systems when fighting in Pokémon GoPokémon systems when fighting in Pokémon Go
    each pokémon system in pokémon go has different strengths, along with a specific weakness. this type of pokémon will have the power to attack the other pokémon, but can defeat the other pokémon. if you know the characteristics of each type, it will be easier to choose which pokémon to battle.
  • The terms you need to know when playing Pokémon GoThe terms you need to know when playing Pokémon Go
    pokémon go is the most prominent name in recent days. this game of capturing and training virtual animals has created a relatively new way of playing, as players have to constantly move to catch pokémon. during the process of joining pokémon go, you will encounter and use a lot of important terms. so what do they mean?
  • How to play Pokemon GO on Windows computersHow to play Pokemon GO on Windows computers
    recently, pokemon go has become a popular game, attracting thousands of gamers around the world. in previous posts network administrator has guided you on how to play pokemon go on android devices and ios devices. in the article below, network administrator will guide you how to play pokemon go on windows computers using bluestacks emulator software.
  • How to become a good Pokémon Go hunter?How to become a good Pokémon Go hunter?
    with a new way of playing, pokémon go has created a new phenomenon in the game village around the world. players will have to go around and find pokémon for themselves. so how to quickly catch pokémon and in large numbers?
  • Things to know to upgrade Pokémon in Pokémon GoThings to know to upgrade Pokémon in Pokémon Go
    the whirlwind pokémon go has spread its power right on the first day of its release. everyone rushed to the street to find a pokémon for themselves. therefore, in order to become a pokémon hunter, you need to master the basics of participating in pokémon go battlefield.
  • List of medals received in Pokemon GoList of medals received in Pokemon Go
    in addition to getting items when leveling up, gamers who join pokemon go also have the opportunity to receive their proud achievements.