Git Tutorial - bounswe/bounswe2024group11 GitHub Wiki
Git is a version control system that allows users to work on a project simultaneously. It keeps track of the changes to the files, enables users to return to any version of the code and enables users to work collaboratively.
You can access the documentation on merging and resolving conflicts
To install Git, visit Git Website and follow the instructions for your workspace.
Configure your Git username and email address so that the Git can associate your commits with your username.
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Navigate to your project directory and initialize a Git repository using the command git init
. This command creates a folder named .git
Use git status
to see untracked files, changes not staged for commit and changes to be committed.
Use git add <file>
to add the files to the staging area.
Use git commit -m "your commit message"
to commit the staged changes to the Git repository.
Use git branch <branch_name>
to create a new branch in the repository. The changes in this branch will not affect the other branches.
Use git checkout <branch_name>
to switch to a different branch. You can combine creating and switching to a new branch by using git checkout -b <branch name>
First, switch to the target branch. git checkout <target_branch>
. Second, merge it with the source branch.git merge <source_branch>
. If the target branch is an ancestory of the source branch, the merge is done by the fast-forward method. If not, it is done by the recursive method.
You can clone a remote repository to your local using git clone <url>
command.
You can make changes to the repository in the local and push them to the remote repository using git push <remote_name> <branch_name>
You can fetch changes from the remote repository and merge them using git pull <remote_name> <branch_name>
You can fetch changes in all branches without merging them with your repository, you can use git fetch <remote_name>
. If you want to fetch only a specified branch, you can use git fetch <remote_name> <branch_name>