Git and GitHub are two of the coolest technologies around for developers. Git, despite its complexity and rather terse beginnings, is the version control tool of choice for everyone from web designers to kernel developers.
Let me share a few quick pointers to get you started on Git:
- Create a new repository on GitHub.
- Open Terminal.
- Change the current working directory to your local project.
- Initialize the local directory as a Git repository.
- Download file from GitHub to local Repo.
git clone <GitHub Repo URL>
- Add the files in your new local repository. This stages them for the first commit. (This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository)
git add . # Adds all the new files
git add -u # updates tracking for files that changed names or were deleted git add -A # does both of the previous
- Commit the files that you’ve staged in your local repository.
git commit -m "useful commit message" (is local action only) # Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
- In Terminal, add the URL for the remote repository where your local repository will be pushed.
git remote add origin <remote repository URL> # Sets the new remote
git remote -v # Verifies the new remote URL
- Push the changes in your local repository to GitHub.
git push -u <REMOTENAME> <BRANCHNAME>
# Pushes the changes in your local repository up to the remote repository you specified as the origin
You can read more on these concepts from : https://git-scm.com/book/en/v2/