Git is an open-source distributed version control system and allows you to manage your source code history efficiently. The version control allows us to track and work together with our team members at the same workspace. Whenever you work on your code, changes can be saved with Git and you can jump back to any previously saved versions. Without tools like Git, you would have to create manual copies of your code, which would be quite cumbersome and impossible to maintain once your application grows.
Git vs Github
Git is a version control system which you can download to your computer, GitHub is a hosting & collaboration provider which hosts your Git projects. It is a web based solution allowing you to upload your Git Repositories to it.
Uploading your code from your local Git environment to GitHub makes your code available to anybody who wants to contribute to your project.
How to Install & Use Git
Git is for free and can be downloaded here.
Git runs in the terminal (MacOS) or the Command Prompt (Windows) only, so it doesn't come with a Graphical User Interface (GUI). Make sure to dive into dedicated resources on that in case these terms are totally new to you.
Useful Git Commands
git init: Initialize a Git repository in the current folder
git status: Show the current status of your Git repository (the "working tree" status)
git add .: Track changes of all files in your Repository
git commit -m "your message": Save updated code to a new Commit named "your message"
git log: List all Commits inside your Branch
git checkout branch-name: Jump to the last Commit of a Branch
git checkout commitid Jump to a specific Commit of a Branch (commitid should be the ID of the Commit you want to checkout)
git checkout -- .: Jump back to the last Commit and remove any untracked changes
get reset --hard: Turn the selected Commit into the new HEAD
git branch: List all Branches inside your Repository
git checkout -b branch-name: Create a new Branch named branch-name
git merge branch-name: Merge two Branches, branch-name is the Branch you merge with the Branch you're currently working in
git branch -D branch-name: Delete the Branch named branch-name
Useful Topic
Git how do you revert a commit that has already been pushed and made public
No comments:
Post a Comment