fdsa After you have git installed on your PC (https://git-scm.com/) follow the following steps to connect to the git repo.
Create an empty folder and navigate to it in terminal (on the Windows git client if you right click in your folder there should be an 'open git console' or similar button)
type in: git init
At this point you should get a message that your git repo has been initialized, you now have your own local git repo on your computer, now you need to connect it to the server
whereby: is the name of the remote server, can be whatever you want it to be is the URL of the repository, in most cases this will end with a .git
example: git remote add gitlab https://git.sviridov.us/seniorProject/WIE.git
(This will add a remote git connection called gitlab to this repository)
Git works by creating a copy of the remote git repository on your computer, this is not done automatically and has to be done through a command. You will need to execute this command every time you want to download updates from the remote server. This will not work if you have uncommited changes on your local git repo. You must either commit (git commit) or stash (git stash) your changes prior to doing a pull (this is covered later)
whereby: is the name of the remote server (the name you gave it during remote add) is the name of the branch you want to pull from (if you want to pull from the main branch use branch name "master")
At this point if the git repository requires permissions to pull from (this one does) it would ask you for your username and password, this is the same username/password as you use on gitlab
At this point you should have a copy of the repository in your folder you created earlier. At this point you are free to work on, modify, create or delete any files in the repository. If you add a new file however, you must add it to the git repository by using an add command:
whereby: is the file name of your new file
You may also use the * character as the wildcard or use it to add all files in the repository folder:
Note: You only need to use git add for new files, modified files and deleted files are tracked automatically
At any point that you want to save your work to the git repo, you can use the commit command:
This will bring up a text editor where you can write a description of the changes you made. After you save the file, the commit will go through.
After your commits, you can push these commits to the server using the push command:
whereby: is the name of the remote server (the one you gave earlier) is the name of the branch you want to push to (just like in pull, you can use "master" if you want to push to the main branch)
Your changes should now be reflected on the gitlab website
If you want to save a default remote server and branch, you can add -u to your pull or push command, that way it will save the server and branch as an upstream remote, meaning that you no longer need to specify it (so you can just do "git push" instead of "git push gitlab master" for instance)
Reset - If you made a mistake and want to revert back to the last commit you can use git revert:
Note: This is a permanent reset, all your uncommitted changes will be permanently deleted. If you still want to keep them I'd recommend just creating a new branch either through gitlab or by using:
whereby: is the name of your new branch
From this point on, you'll be switched over to your new branch and any commits you make will be to your new branch while the other branhc will be untouched
To switch to a different branch you can use the checkout command without -b
whereby: is the branch name you want to switch to
After you switch to a branch any commits you make will be to this branch.
Remember to push all your changes to the remote server as all your changes are only stored locally until you do a git push
revert: If for whatever reason you want to go back to a previous commit you can use the commit id to go to any previous commit. commit ids can be found when you go to repository -> commits on the sidebar in gitlab, commit ids will be on the right of the commit
whereby: is the id of the commit you want to revert to
If you also want to move that commit to a new branch use:
whereby: is the name for your new branch is the id of the commmit you want to rever to.