There are four fundamental elements in the Git Workflow.Working Directory, Staging Area, Local Repository and Remote Repository.
In order to run any code in a Github repository, you will need to either download it or clone it to your machine. Click the green "clone or download repository" button on the top right of the repository. In order to clone, you will need to have git installed on your computer.
Have a look at git for designers for great one page article/high level intro to the topic. (That link is broken: Here is a link to another Git for Designers )
I would start at http://git-scm.com/documentation, there are documents and great video presentations for non-software-developer/cs users. Git for beginners have some basic stuff.
I really like the O'Reilly book "Version Control with Git". I read it cover-to-cover and now I'm very comfortable with advanced git topics.
git clone your-url local-dir
to checkout source code;
git pull
to update source code in local-dir;
You might want to start with an introduction to version control. This guide is specific to subversion, but the core concepts can be applied to most version control systems. After you have the basics, you can delve into the git guide.
I think gitready is a great starting point. I'm using git for a project now and that site pretty much got the ball rolling for me.
To answer your questions directly rather than pointing you at documentation:
1) In order to keep it up to date, do a git pull and that will pull down the latest changes in the repository, on the branch that you're currently using (which is generally master)
2) I don't think there's something (widely available) that'll do this for you. To update them follow 1) for all projects.
Using Git for version control
Visual studio code have Integrated Git Support.
Install Git : https://git-scm.com/downloads
1) Initialize your repository
Navigate to directory where you want to initialize Git
Use git init command This will create a empty .git repository
2) Stage the changes
Staging is process of making Git to track our newly added files. For example add a file and type git status. You will find the status that untracked file. So to stage the changes use git add filename. If now type git status, you will find that new file added for tracking.
You can also unstage files. Use git reset
3) Commit Changes
Commiting is the process of recording your changes to repository. To commit the statges changes, you need to add a comment that explains the changes you made since your previous commit.
Use git commit -m message string
We can also commit the multiple files of same type using command git add '*.txt'. This command will commit all files with txt extension.
4) Follow changes
The aim of using version control is to keep all versions of each and every file in our project, Compare the the current version with last commit and keep the log of all changes.
Use git log to see the log of all changes.
Visual studio code’s integrated git support help us to compare the code by double clicking on the file OR Use git diff HEAD
You can also undo file changes at the last commit. Use git checkout -- file_name
5) Create remote repositories
Till now we have created a local repository. But in order to push it to remote server. We need to add a remote repository in server.
Use git remote add origin server_git_url
Then push it to server repository
Use git push -u origin master
Let assume some time has passed. We have invited other people to our project who have pulled our changes, made their own commits, and pushed them.
So to get the changes from our team members, we need to pull the repository.
Use git pull origin master
6) Create Branches
Lets think that you are working on a feature or a bug. Better you can create a copy of your code(Branch) and make separate commits to. When you have done, merge this branch back to their master branch.
Use git branch branch_name
Now you have two local branches i.e master and XXX(new branch). You can switch branches using git checkout master OR git checkout new_branch_name
Commiting branch changes using git commit -m message
Switch back to master using git checkout master
Now we need to merge changes from new branch into our master Use git merge branch_name
Good! You just accomplished your bugfix Or feature development and merge. Now you don’t need the new branch anymore. So delete it using git branch -d branch_name
Now we are in the last step to push everything to remote repository using git push
Hope this will help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With