0% found this document useful (0 votes)
113 views

Git Basic Usage Installation

Uploaded by

el craft arias
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views

Git Basic Usage Installation

Uploaded by

el craft arias
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Git Basic Usage

Installation
Download and install git for your OS (Windows, Linux or Mac OS X)
https://git-scm.com/downloads
Open a command line prompt and run:
$ git --version

Fork the repository


A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes
without affecting the original project.
Fork your repo from https://github.com/devops-at06

Configure your global Git account.


Open a command line prompt and run:
$ git config --global user.name "First_Name Last_Name"
$ git config --global user.email [email protected]

Testing your SSH connection


$ ssh -T [email protected]

Workflow for Git feature branching (Command prompt)


Open a command line prompt.
1. Start with the master branch
This workflow helps you collaborate on your code with at least one other person. As long as your
GitHub and local repos are up-to-date, you're ready to get started.
$ cd <USER_HOME> (e.g. /home/ubuntu or c:\Users\usuario )
$ git clone https://github.com/fercho-ayala/TRAINER-1

2. Create a new-branch
Use a separate branch for each feature or issue you work on. After creating a branch, check it out
locally so that any changes you make will be on that branch.
$ cd <USER_HOME>
$ cd TRAINER
$ git checkout -b feature
3. Update, add, commit, and push changes
Work on the feature and make commits like you would any time you use Git. When ready, push your
commits, updating the feature branch on GitHub

$ cd <USER_HOME>
$ cd TRAINER
$ git add .
$ git commit -m "Adding a change from the feature branch."
$ git push origin feature
4. Get your code reviewed
To get feedback on your code, create a pull request in GitHub. From there, you can add reviewers and
make sure everything is good to go before merging.
5. Resolve feedback
Now your teammates comment and approve. Resolve their comments locally, commit, and push
changes to GitHub. Your updates appear in the pull request.
6. Merge your pull request
Before you merge, you may have to resolve merge conflicts if others have made changes to the repo.
When your pull request is approved and conflict-free, you can add your code to the master branch.
Merge from the pull request in Github.

Syncing a fork - Configure a remote for a fork


1. List the current configured remote repository
$ git remote -v
2. Add new remote upstream repository that will synced with the fork
$ git remote add upstream https://github.com/devops-at06/TRAINER
3. Fetch the branches
$ git fetch upstream
4. Check out your fork’s local master branch
$ git checkout master
5. Merge the changes from upstream/master into your local master branch.
$ git merge upstream/master
6. Push the changes to your fork
$ git push origin master
Basic Git command reference
➢ $ git config - Configure Git
➢ $ git init - Initialize Git repository
➢ $ git clone - Create an empty Git repository
➢ $ git status - Check the status of a Git repository
➢ $ git add - Track files
➢ $ git commit - Commit tracked files
➢ $ git push - Upload files
➢ $ git pull - Download files
➢ $ git log - Display commit history
➢ $ git switch -Switch branches

References
➢ https://git-scm.com/docs
➢ https://guides.github.com/activities/hello-world/
➢ https://guides.github.com/introduction/flow/
➢ https://guides.github.com/activities/forking/
➢ https://help.github.com/articles/fork-a-repo/
➢ https://help.github.com/articles/configuring-a-remote-for-a-fork/
➢ https://help.github.com/articles/syncing-a-fork/

You might also like